[英]CakePHP 1.3 - Getting nested data from Form->input()?
I'm upgrading a system from CakePHP 1.1 to CakePHP 1.3. 我正在将系统从CakePHP 1.1升级到CakePHP 1.3。 In 1.1 I was able to use the HTML helper to do something like: 在1.1版中,我能够使用HTML帮助器执行以下操作:
$html->input('User/email');
To get back data nested in: 要获取嵌套在其中的数据:
$this->data['User']['email']
In the controller. 在控制器中。 Now I know that $html->input()
has been replaced with $this->Form->input()
. 现在我知道$html->input()
已替换为$this->Form->input()
。 However, when I try to use: 但是,当我尝试使用时:
$this->Form->input('User/email')
I get: 我得到:
Undefined offset: 2 [CORE\cake\libs\view\helpers\form.php, line 496]
This is coming up because the /
in the input. 这是因为输入中的/
。 So it seems that 1.3 doesn't like using the /
to specify the data should be returned nested. 因此,似乎1.3不喜欢使用/
来指定应嵌套返回的数据。 How might I achieve the equivalent of this in 1.3? 如何实现1.3中的等效功能? Thank you much! 非常感谢!
In 1.3 you would use 在1.3中,您将使用
$this->Form->input('User.email');
To set an input for the User model and the email field. 为用户模型和电子邮件字段设置输入。
If you have set up your form correctly though, you just need email
如果您正确设置了表格,则只需要email
For example 例如
$this->Form->create('User');
$this->Form->input('email');
$this->Form->end('Submit');
But in short, to answer your specific question, replace the / with a . 简而言之,要回答您的特定问题,请用代替/。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.