【发布时间】:2015-03-26 09:21:59
【问题描述】:
我正在尝试为性别添加一个表单字段,下面是我的代码:
$options = ['m' => '男', 'f' => '女']; echo $this->Form->select('gender', $options);
但在我的视图文件中,我看不到 lebel 性别是否有任何其他代码可以帮助我提出建议。
【问题讨论】:
标签: forms cakephp-3.0
我正在尝试为性别添加一个表单字段,下面是我的代码:
$options = ['m' => '男', 'f' => '女']; echo $this->Form->select('gender', $options);
但在我的视图文件中,我看不到 lebel 性别是否有任何其他代码可以帮助我提出建议。
【问题讨论】:
标签: forms cakephp-3.0
From->select 没有给出正确的标签。做吧:
echo $this->Form->input('gender', array(
'options' => $options,
'type' => 'select',
'empty' => 'Select the gender',
'label' => 'Gender'
)
);
【讨论】:
<?= $this->Form->select('gender', ['m' => 'Male', 'f' => 'Female'], ['class' => 'form-control', 'required' => true])?>
【讨论】: