【问题标题】:Laravel obtain the selected value from a Form::SelectLaravel 从 Form::Select 获取选定的值
【发布时间】:2014-01-30 03:42:51
【问题描述】:

您好,我有一个名为 $crit 的数组,我在其中放置了 HTML 表单组件的值 例如这个输入:

{{ Form::label('name', 'Name:', array('class'=>'label'))}}
{{ Form::text('name', isset($criteria['name'])?$crit['name']:'', array('id'=>'name', 'class'=>'input'))}}<br/>

我想对 select 组件做同样的事情,但我不知道如何将所选性别的值添加到我的 $crit 数组中。

{{Form::label('Sex', 'Sex:', array('class'=>'label'))}}
{{Form::select('sex', $options, 'M', array('id'=>'sex'))}}

在我看来,我已经定义了数组$options

public function get_index()
{
    return View::make('personal.data')
    ->with('options', array('M' => 'Male', 'F' => 'Female'))
}

感谢您的回答,问候

【问题讨论】:

    标签: php laravel


    【解决方案1】:

    您只需使用Input::old,它将在重定向/错误时重新填充

    {{ Form::select('sex', $options, Input::old('sex')) }}
    

    【讨论】:

      猜你喜欢
      • 2017-03-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-23
      • 1970-01-01
      • 1970-01-01
      • 2019-10-28
      相关资源
      最近更新 更多