我如何更改cakephp中输入的名称

How can i change the name of the input in cakephp

我想更改输入的名称以使其成为 name=data[Contact][firstname] 因为我想在单击 edit() 时显示数据我想这就是它不显示的原因。 echo $this->Form->input('First Name:', array('class'=>'form-control')); 输入名称与第一个参数相同。请帮忙

你的代码应该是这样的:

echo $this->Form->input('firstname', array('class'=>'form-control','label'=>'First Name'));

第一个参数是输入域的名称(name="firstname")。它不是标签(名字:)。所以你的代码应该是,

$this->Form->input('firstname', array('class'=>'form-control'));

要获取此结构 [Contact][firstname],您的表单名称应为 'contact'。

$this->Form->create('Contact',array('class'=>'form'));
    $this->Form->input('firstname', array('class'=>'form-control'));