0
我使用cakePHP v2.4,我试图自动填写表单。 我在我的控制器做的是这样的:如何填写表格与蛋糕PHP
$contact = $this->Contact->findById($id);
$this->set('data', $contact);
在我看来,我用德表单助手这样的:
echo $this->Form->create('Person');
echo $this->Form->text('firstname', array('label' => 'Firstname'));
echo $this->Form->end();
我想我的输入姓名被自动填充我得到的值从我的要求。这是我所得到的,当我在我看来,做PR($数据):
Array
(
[Contact] => Array
(
[id] => 15
[created] => 0000-00-00 00:00:00
[modified] => 0000-00-00 00:00:00
[type] => person
)
[Person] => Array
(
[contact_id] => 15
[firstname] => eric
)
)
正如你所看到的,我有一个表“联系我们”,并根据类型,无论是“人”或“公司'我将加载相应的表格。 我不知道我在这里错过了什么,但我还没有找到答案。
完美,我做了$ this-> request-> data = $ this-> Contact-> findById($ id),它的工作原理:)谢谢! – user2688870