user3714121
user3714121

Reputation: 13

Multiple select dropdown in laravel

Here is my code in the view, I want to display a dropdown that contains the selected data in an edit view.

{{Form::select('Select_targets[]', $_targets,Input::old('Select_target', $profile->Target_idTarget-1), array('multiple' => true))}}

I tried this code but it just displays one selected value. Please I need your help! Thanks in advance

Upvotes: 1

Views: 10893

Answers (2)

Keshab Bhattarai
Keshab Bhattarai

Reputation: 1

use wherein method of laravel incase you want to take all the option as query from request

Upvotes: 0

Björn
Björn

Reputation: 5876

I think you have an error around your old input and default values for the dropdown. Here is a stripped down example that does work:

Controller:

//current selected
$target = 3;

/array with options
$targets[1] = 'target 1';
$targets[2] = 'target 2';
$targets[3] = 'target 3';

return View::make('form')->with('targets',$targets)->with('target',$target);

View:

{{ Form::open() }}
{{ Form::select('targets[]', $targets, Request::old('targets') ? Request::old('targets') : $target, array('multiple' => true)); }}
{{ Form::submit('send') }}
{{ Form::close() }}

Upvotes: 2

Related Questions