SNT93
SNT93

Reputation: 476

Get selected value from drop down Laravel 4

I want to get the selected value from a drop down list in a controller method. The drop down list :

{{ Form::select('Organization',  $organization_list ,Input::old('Organization'), array('class' => 'form-control')) }}

$organization_list is an array of organizations.. I have tried to catch the selected item of this drop down list in a controller as follows:

Input::get('Organization');

But it gives me the array index instead of the real organization name..But the real organization name is shown in drop down list.. does anyone have a solution?

Upvotes: 1

Views: 550

Answers (1)

Coloured Panda
Coloured Panda

Reputation: 3477

Pass an associative array To Form::select as the second argument

$organization_list = array_combine($organization_list, $organization_list); //Copies the array values to keys


{{ Form::select('Organization',  $organization_list ,Input::old('Organization'), array('class' => 'form-control')) }}

http://php.net/array-combine

Upvotes: 2

Related Questions