adamwathan / bootforms

Rapid form generation with Bootstrap 3 and Laravel.
MIT License
417 stars 103 forks source link

Select its not preserving the old input #96

Closed juanitodelcielo closed 8 years ago

juanitodelcielo commented 8 years ago

Fail {!! BootForm::select('Máquinas', 'machines[]')->options($machines)->class('form-control js-select2')->multiple()->select($reference->machines) !!}

Success {{ Form::select('operations[]', $operations, $machine->operations, ['multiple' => 'multiple', 'class' => 'form-control js-select2']) }}

adamwathan commented 8 years ago

The problem is you are using the select method which does a force select, ignoring any old input or model binding.

Use defaultValue instead:

{!! BootForm::select('Máquinas', 'machines[]')->options($machines)->class('form-control js-select2')->multiple()->defaultValue($reference->machines) !!}