2
有沒有辦法將水化策略添加到Zend\Form\Element\Collection
元素中?我嘗試了正常的方式:將策略添加到Zend Form Element Collection中
$hydrator = new ClassMethods();
$hydrator->addStrategy('language', new LanguageStrategy($em));
$hydrator->addStrategy('items', new UnitItemsStrategy($em));
$this->setHydrator($hydrator);
與元素:
$this->add(array(
'type' => 'Zend\Form\Element\Collection',
'name' => 'items',
'options' => array(
'label' => 'Items',
'count' => 1,
'should_create_template' => true,
'allow_add' => true,
'target_element' => array(
'type' => 'Application\Form\UnitItemFieldset',
),
),
));
但水化戰略從來沒有被調用。當我將它重新映射到像text
這樣的其他元素時,它會被調用。所以它似乎與該元素是Zend\Form\Element\Collection
。