这相当简单,但根据文档,我可以执行以下操作:
echo $this->Form->input('name', 'Produkt');
其中'Produkt
将是输入字段的标题。
但是,当我尝试此操作时,出现以下错误:
Warning (2): array_merge(): Argument #3 is not an array [CORE'Cake'View'Helper'FormHelper.php, line 1078]
Notice (8): Unenter code heredefined index: before [CORE'Cake'View'Helper'FormHelper.php, line 992]
Notice (8): Undefined index: between [CORE'Cake'View'Helper'FormHelper.php, line 992]
Notice (8): Undefined index: after [CORE'Cake'View'Helper'FormHelper.php, line 992]
Notice (8): Undefined index: format [CORE'Cake'View'Helper'FormHelper.php, line 1200]
我做错了什么?
请注意,我还尝试了以下方法:
echo $this->Form->input('antal', array('title'=>'På lager'));
$options = array()
input
的方法签名为:
public function input($fieldName, $options = array()) {
在该方法需要数组的位置传递字符串将不起作用。如果有一些文档表明这应该有效 - 请指出它和/或提交一个补丁来纠正它。
要设置输入的标题,只需将其指定为选项的一部分:
echo $this->Form->input('name', array('label' => 'Produkt'));
关于这点:
将数组请注意,我还尝试了以下方法...
作为第二个参数传递不会导致数组合并错误,因为相关变量将是一个数组。如果有其他错误消息,请指出是什么。