3
我正在尝试创建一个页面,其中包含两个字段集,每个字段集应该填充不同的表。ZF2 Fieldsets and Form Binding
我可以轻松地创建一种形式作为专辑的教程,并绑定该数据是这样的:
$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
,但如果我把这些元素到字段集的绑定不再起作用,除此之外,我需要将每个字段集绑定到一个单独的表,并且一旦表单被引用,他们需要保存到单独的表中。
我该如何解决这个问题,我想我可以使用两种形式来实现,但这可能不是正确的方法(如果我正确理解fieldset的概念)?
谢谢!我会试试这个。 – Juan
好的,我想我仍然错过了一些东西,当我需要编辑产品时,我在哪里放置绑定?因为我不能绑定任何字段集我该如何告诉表单绑定一个特定的对象呢? – Juan