对Form有点问题,求教,谢谢

  1. FORM 的radio怎么设置?比如下面的这个

<div class="form-group row">
        {!! Form::label('sex','性别',['class' => 'col-md-2 control-label']) !!}
        <div class="radio radio-primary col-md-10">
            <label>
                <input type="radio" name="sex" id="optionsRadios1" value="未知" checked="">未知
            </label>
            <label>
                <input type="radio" name="sex" id="optionsRadios1" value="男" checked=""></label>
            <label>
                <input type="radio" name="sex" id="optionsRadios2" value="女"></label>
        </div>
    </div>
  1. FORM中得Select默认用的value是数字,但我想直接用有语义要存储的内容为Value,怎么做?或者说数字传到后面之后怎么做更有效地对应?
    我现在是这样做的

<div class="form-group row">
       {!! Form::label('relationship_status','情感状况',['class' => 'col-md-2 control-label']) !!}
        <div class="col-md-10">
            {!! Form::select('relationship_status',$data['status'],null,['class'=>'form-control']) !!}
        </div>
    </div>

$data['status']现在用的是传入的数组 用来显示选项

 $status = array('未知', '单身', '恋爱', '订婚', '已婚', '离异', '丧偶');

谢谢

AGuier

最简单就

$status = array('未知',=>'未知', '单身'=>'单身'……);
woailuosj

@AGuier 不大理解,是指 array(‘表单的值’=>‘数据表中字段’)吗?

AGuier

把你想要的 select 呈现出来。
@woailuosj

woailuosj

@AGuier 额,我试了下,select里的value还是 数字啊,

woailuosj

@AGuier 恩,我改了改,select那个解决了问题,但是radio如何实现FORM binding的?

woailuosj

@AGuier 好的谢谢