adamwathan / bootforms

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

Question : Default values on a multiple select #62

Closed MarlBurroW closed 9 years ago

MarlBurroW commented 9 years ago

Hello,

I just would like to know how to set multiple default values for a select with the "multiple" attribute.

I've tried to do something like this :

$tagOptions = array( 'tag1'=>'Tag 1', 'tag2'=>'Tag 2', 'tag3'=>'Tag 3' );

BootForm::select('Tags','tags[]', $tagOptions)->attribute("multiple","multiple")->select(array('tag1','tag3'));

But the select method works only to select a single value.

Thank you very much

adamwathan commented 9 years ago

Hey, you can set default values for multiselects like so:

BootForm::select('Tags', 'tags[]', $tagOptions)->multiple()->defaultValue(array('tag1', 'tag3'));

I should update the select() method to work the same way as well though :+1:

adamwathan commented 9 years ago

Actually this seems to already work, what version of the package are you on? This functionality was added in a semi-recent pull request, so I think you'll need to be on 0.6.3.

MarlBurroW commented 9 years ago

I was on "v0.2" lol ! I've updated to "v0.6.3" and it works fine now.

Thank you so much !