eloquent - laravel collective form database autoselect -
i have forms store data in db, next time when open page want autoselected values selected already
{!! form::select('week_starts', [ 'monday' => 'monday', 'tuesday' => 'tuesday', 'wednesday' => 'wednesday', 'thursday' => 'thursday', 'friday' => 'friday', 'saturday' => 'saturday', 'sunday' => 'sunday' ]) !!}
so need form check db (that's not problem) , if found in database example monday , tuesday these fields autoselected param selected=true
any idea how that. tried <?php if... ?>
not working inside {!! ... !!}
you should pass , id of selected option as third parameter:
{!! form::select('week_starts', [ 'monday' => 'monday', tuesday' => 'tuesday', wednesday' => 'wednesday', thursday' => 'thursday', friday' => 'friday', saturday' => 'saturday', sunday' => 'sunday' ], 'friday') !!}
you should data db in controller or model , pass variable view.
or use form::model
binding, in case id set automatically.
Comments
Post a Comment