我的选择表单工作正常,但无论参数如何变化或排列,我的标签都不会显示。
这是我的代码:
<?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
。我做错了什么吗?或者这是不可能的或者是一个错误?
最佳答案
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
参数集。
关于输入选择表单上的 CakePHP 标签选项未按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4949669/