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

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -