Laravel从Form :: Select获取选择的值 [英] Laravel obtain the selected value from a Form::Select
本文介绍了Laravel从Form :: Select获取选择的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,我有一个名称为$crit
的数组,在其中放置了HTML表单组件的值
例如,此输入:
Hello I have an array with name $crit
where I put the value of my HTML form components
for example this input:
{{ Form::label('name', 'Name:', array('class'=>'label'))}}
{{ Form::text('name', isset($criteria['name'])?$crit['name']:'', array('id'=>'name', 'class'=>'input'))}}<br/>
我想对select组件做同样的事情,但是我不知道如何将所选性别的值添加到我的$crit
数组中.
I want to do the same with the select component but I don't know how to add the value of the selected sex to my $crit
array.
{{Form::label('Sex', 'Sex:', array('class'=>'label'))}}
{{Form::select('sex', $options, 'M', array('id'=>'sex'))}}
在我看来,我已经定义了数组$options
On my view I have defined the array $options
public function get_index()
{
return View::make('personal.data')
->with('options', array('M' => 'Male', 'F' => 'Female'))
}
感谢您的问候,
推荐答案
您只需使用Input::old
,它将在重定向/错误时重新填充
You just use Input::old
and it'll be re-populated on redirect/error
{{ Form::select('sex', $options, Input::old('sex')) }}
这篇关于Laravel从Form :: Select获取选择的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文