Skip to content

Instantly share code, notes, and snippets.

@unisys12
Last active February 24, 2022 14:30
Show Gist options
  • Save unisys12/9f01b3ee4f114ff34ceea598d2effefd to your computer and use it in GitHub Desktop.
Save unisys12/9f01b3ee4f114ff34ceea598d2effefd to your computer and use it in GitHub Desktop.
Generating a Select element with pre-selected options...
<select name="tags[]" id="tags" multiple>
@foreach ($tags as $tag)
<option value="{{ $tag->id }}"
@foreach ($quote->tags as $quote_tag)
@if ($tag->id == $quote_tag->pivot->tag_id) selected @endif
@endforeach
>
{{ $tag->name }}
</option>
@endforeach
</select>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment