3

Hello im using this code for a multiple select form

{{ Form::select('language', $language, null, array('multiple' => true, 'multiple class' => 'chosen-select form-control')); }}    

but this code only send the last input to database, ive searched and found to attach this [ ] to the name like this

{{ Form::select('language[]', $language, null, array('multiple' => true, 'multiple class' => 'chosen-select form-control')); }}   

But with this code i cant save the data, did you know why?
Thank you

2
  • Have a look here: stackoverflow.com/questions/24768327/… Commented Dec 19, 2014 at 19:11
  • Thank you for the link, im using another script but i need it in the future Commented Dec 19, 2014 at 22:33

1 Answer 1

2

The name attribute in the html tag must have the brackets; however, when you grab the input in your controller you must not include the brackets.

View:

{{ Form::select('language_ids[]', $languagesArray, defaultSelectionsArray, ['multiple' => 'true']) }}

Controller:

public function store() {
    $languageIds = Input::get('language_ids');
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.