4 years ago

Form::select() with a default value that doesn't exist in the list

Posted 4 years ago by CrtlAltDylan

I have a model that has a "new" option in case the user doesn't want any of the other sectionPrototypes they have made.

I would like to use "New Section" as the default value, but since there is no sectionPrototype in the list, Laravel doesn't show any option whatsoever.


<div class="row">
     {{ Form::select('sectionPrototypes', $currentUser->sectionPrototypes->lists('name', 'id'), 'New Section') }}

Screenshot of empty select box:

I'd much rather use the Blade Form, because it's so much cleaner of an implementation. However if I can't use the default value, I'm kind of screwed because a user has no sectionPrototypes when they first create an account.

Please sign in or create an account to participate in this conversation.