I just discorvered that Form::model
binding existed and I'm delighted with (it's wonderful). I tried it with text, email, and even select, every single time it worked.
My question is, will it work with a <select multiple>
? If it does, how am I supposed to use it and what is the correct way to save an array in the database? (This may be awful but I concatenate all the options of the array with a separator and save it as text, I'm sure it's not the correct way to do it).
just like this :
Form::select('menus[]', $menus, null, array(
'multiple' => true,
'class' => 'form-control'
));
take a note :
param 1 : should be your field name (if want multiple add array tag aftrer field name e.g :menus[]
)
param 2 : list menu (array) e.g : array('value1' => 'text1', 'value2' => 'text2')
param 3 : selected values. (should be null
because Form::model
will perform automatically matching values from database. and make sure the field name has same with key
data result from database)
param 4 : is property for element <select>
you can add class, id, and etc..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With