2014-05-12 39 views
0

我正在使用一個Fieldset的表單工作,我無法讓表單正常工作與水化器。ZF2 - 表格fieldset

我有什麼:

Base.php 命名空間CMS \表格\ CMS;

use Zend\ServiceManager\FactoryInterface; 
use Zend\InputFilter\InputFilterProviderInterface; 
use Zend\Authentication\AuthenticationService; 
use Zend\Form\Form; 
use Zend\Form\Fieldset; 

use Zend\Stdlib\Hydrator\ObjectProperty as ObjectPropertyHydrator; 


public function __construct() { 

$this->setAttribute('method', 'post') 
    ->setHydrator(new ObjectPropertyHydrator(false)); 

$this->add(array(
    'name' => 'id', 
    'type' => 'Hidden', 
)); 
$this->add(array(
     'name' => 'title', 
     'type' => 'Text', 
     'required' => true, 
     'options' => array(
      'label' => _('Menu titel'), 
    ), 
)); 
$meta = new \Cms\Form\Cms\Meta('meta'); 
$meta->setUseAsBaseFieldset(false); 
$this->add($meta); 

Meta.php

public function __construct($name = null) 
{ 
    parent::__construct('meta'); 
    $this->setHydrator(new ObjectPropertyHydrator(false)) 
      ->setObject(new \Cms\Entity\MetaEntity()); 

    $this->setLabel('Meta'); 

    $this->add(array(
      'name' => 'seo_meta_title', 
      'type' => 'Text', 
      'options' => array(
      'label' => _('Title'), 
     ), 
    )); 

     } 

控制器 ....

$cms = $this->getCmsable()->byId($id); 

$form = new Base('add'); 
$form->bind($cms); 

的形式工作的罰款,直到我添加的額外字段集。 如果我使用setUseAsBaseFieldset選項,則僅設置true-> fieldset字段 false->僅設置主窗體。

我檢查了所有的數據,它是存在的。

我認爲這與水化器有關。 有人可以給我一些建議嗎?

回答

-1

我無法準確得出你的問題,你是什麼意思的最後一部分「如果我使用setUseAsBaseFieldset選項,true-> fieldset字段只設置false->只有主窗體設置。」 但是here是相同實現的工作示例,即fieldset和ObjectPropertyHydrator。 希望它有幫助

+0

鼓勵與外部資源的鏈接,但請在鏈接的周圍添加上下文,以便您的同行用戶可以瞭解它是什麼以及它爲什麼在那裏。如果目標網站無法訪問或永久離線,請始終引用重要鏈接中最相關的部分。 –

+0

@AndrewStubbs「同一實現的工作示例,即fieldset和ObjectPropertyHydrator」的哪一部分你不能得到?我寫了這個聲明,因爲那是什麼鏈接。你需要更多的環境?我不太關心你投票的結果,但那是...... –

+0

**如果目標網站無法訪問或永久離線**,請務必引用重要鏈接中最相關的部分。如果遠程資源發生變化,您的帖子將完全無用 –