CrtlAltDylan
4 years ago
269
3
General

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.

Code:

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

Screenshot of empty select box: http://puu.sh/dyXjD/df9c4a82a3.png

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.