簡體   English   中英

獲取所選下拉列表的值Laravel 4

[英]Getting the value of a selected drop down list Laravel 4

我已經嘗試尋找他,但不幸的是我還沒有解決方案。 希望有人可以幫助我。 我正在嘗試獲取此選擇表單的選定輸入:

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"')) }} 

這是我在控制器上傳遞的內容:

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

要在刀片模板上進行查看,我需要投入什么?

您需要使用:

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

因為在第三個參數中,您傳遞了所選元素的值。

編輯

如果只想顯示它,則應使用

{{{ $adult }}}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM