staphhelpme
staphhelpme

Reputation: 65

Getting the value of a selected drop down list Laravel 4

I have tried searching for his and unfortunately I haven't got the solution yet. Hope someone could help me with this. I am trying to get the selected input of this select form:

onewayflight.blade.php

{{ Form::label('adult','Adults: ') }} 
           {{ Form::select('adult', ['12+'=>'12+ years',
                                    '1'=>'1','2'=>'2',
                                    '3'=>'3','4'=>'4',
                                    '5'=>'5','6'=>'6',
                                    '7'=>'7','8'=>'8',
                                    '9'=>'9','10'=>'10',
                                    '11'=>'11','12'=>'12',
                                    '13'=>'13','14'=>'14',
                                    '15'=>'15','16'=>'16',
                                    '17'=>'17','18'=>'18',
                                    '19'=>'19','20'=>'20'],'1',array('class'=>'class="btn btn-default dropdown-toggle"')) }} 

This is what I've passed on my controllers:

$a = Input::get('adult');
    return View::make('content.onewayflightresults')->with('adult',$a);

What would I be throwing in for it to be viewed on a blade template?

Upvotes: 0

Views: 1589

Answers (1)

Marcin Nabiałek
Marcin Nabiałek

Reputation: 111829

You need to use:

{{ Form::select('adult', [/* here your array */],$adult,array('class'=>'class="btn btn-default dropdown-toggle"')) }}

because in 3rd parameter you pass value of selected element.

EDIT

If you want just display it, you should use

{{{ $adult }}}

Upvotes: 1

Related Questions