php - populate select in Laravel form with value from model -
i made form select. here code:
{!! form::model($customeraccount, ['route' => ['admin.customeraccount.update', $customeraccount->id_customer_account], 'method' => 'put', 'class' => 'form-horizontal']) !!}
...
<div class="@if ($errors->has('cacct_active'))has-error has-feedback @endif form-group"> {!! form::label('cacct_active', 'status: *',['class' => 'col-md-4 control-label']) !!} <div class="col-md-8"> {!! form::select('cacct_active',$customeraccount->getstatuslist(),null,['class'=> 'form-control', 'required' => 'required', 'autofocus' => 'none']) !!} </div> </div>
i have options loaded $customeraccount->getstatuslist() , want default selected option value object. not happen, selected first 1 options.
edit
the problem was using 'true, false' values in db , '0, 1' values in 'statuslist' parameter - easiest way solve use mutator 'casts' in model field
Comments
Post a Comment