我有这种情况。从 BiograpiesController 查询后,我得到了这个数组:
Array (
[0] => Array (
[Biography] => Array (
[id] => 7
[biography] => AAA
)
)
[1] => Array (
[Biography] => Array (
[id] => 9
[biography] => BBBBB
)
)
)
在视图中,我想创建一个包含此数据的表单。我用:
echo $this->Form->create( 'Biography' ));
echo $this->Form->input( '0.Biography.biography', array( 'label' => 'A' ));
echo $this->Form->input( '1.Biography.biography', array( 'label' => 'B' ));
echo $this->Form->end( );
第一个字段填充了正确的数据,第二个字段为空。然后我尝试:
echo $this->Form->input( 'A1', array( 'type' => 'textarea', 'rows' => '10', 'cols' => '40', 'value' => $this->request->data[0]['Biography']['biography'] ));
echo $this->Form->input( 'B1', array( 'type' => 'textarea', 'rows' => '10', 'cols' => '40', 'value' => $this->request->data[1]['Biography']['biography'] ));
字段 A1 填充了正确的数据,第二个字段为空。为什么会这样?如何使用控制器中的正确数据填写表格?
非常感谢