我的选择表单工作正常,但无论参数的变化或排列如何,我的标签都不会显示。
这是我的代码:
<?php echo $this->Form->input('plan_detail_id', $plans_list, array(
'type' => 'select',
'label' => 'Select a the Plan Detail',
'empty' => '-- Select a the Plan Detail --'
)); ?>
正如您所看到的,我有第二个参数$plan_list
,它通常是标签标签的位置。例如,我的所有其他标签都可以:
<td><?php echo $this->Form->input('age_id', array(
'label' => 'Select an Age Range',
'empty' => '-- Select an Age Range --'
)); ?></td>
注意:第一个例子没有第二个$argument
。我做错了吗?或者这不可能或是一个错误?
答案 0 :(得分:8)
The API doesn't show three parameters到FormHelper::input
方法;只有$fieldName
和$options
。您可能打算使用FormHelper::select
方法。
$this->Form->select('plan_detail_id', $plans_list, null, array('label' => 'Select a the Plan Detail', 'empty' => '-- Select a the Plan Detail --'));
请注意,FormHelper::select
不包含换行<div>
或标签。要做到这一点,你必须传递这样的东西..
echo $this->Form->input(
'plan_detail_id',
array(
'options' => $plans_list,
'type' => 'select',
'empty' => '-- Select a the Plan Detail --',
'label' => 'Select a the Plan Detail'
)
);
这与您最初的尝试不同,它将$plans_list
移动到设置了options
参数的数组中。