CakePHP 1.3 -从Form- input()中获取嵌套数据


CakePHP 1.3 - Getting nested data from Form->input()?

我正在将CakePHP 1.1系统升级到CakePHP 1.3。在1.1中,我可以使用HTML帮助器做如下事情:

$html->input('User/email');

返回嵌套的数据:

$this->data['User']['email']

在控制器中。现在我知道$html->input()已经被$this->Form->input()取代了。但是,当我尝试使用:

$this->Form->input('User/email')

:

Undefined offset: 2 [CORE'cake'libs'view'helpers'form.php, line 496]

这个出现是因为输入中的/。因此,1.3似乎不喜欢使用/来指定应该嵌套返回的数据。如何在1.3中实现相同的功能?非常感谢!

在1.3版本中,您将使用

$this->Form->input('User.email');

为User模型和email字段设置输入

如果你已经正确设置了表单,你只需要输入email

例如

$this->Form->create('User');
$this->Form->input('email');
$this->Form->end('Submit');

但简而言之,要回答您的具体问题,请将/替换为。