【发布时间】:2013-03-28 12:35:05
【问题描述】:
我正在尝试使用带有两个字段集的表单创建一个页面,每个字段集应填充不同的表。
我可以像相册教程中一样轻松创建一个表单,并像这样绑定数据:
$pageForm = new PageForm();
$pageForm->bind($page);
我的 PageForm 类如下:
class PageForm extends Form
{
public function __construct($name = null)
{
// we want to ignore the name passed
parent::__construct('page');
$this->setAttribute('method', 'post');
$this->add(array(
'name' => 'id',
'attributes' => array(
'type' => 'hidden',
),
));
} /// and a bunch of other elements
但如果我将这些元素放入字段集中,则绑定不再有效,此外我需要将每个字段集绑定到单独的表,并且一旦提交表单,它们需要保存到单独的表中。
我该怎么做,我想我可以使用两种形式来做,但这可能不是正确的方法(如果我正确理解字段集的概念)?
【问题讨论】: