1

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

2 Answers 2

2

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() }}
Sign up to request clarification or add additional context in comments.

Comments

0

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

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

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.