Adding a strategy to a Zend\Form\Element\Collection -
is there way add hydration strategy zend\form\element\collection element? tried normal way:
$hydrator = new classmethods(); $hydrator->addstrategy('language', new languagestrategy($em)); $hydrator->addstrategy('items', new unititemsstrategy($em)); $this->sethydrator($hydrator); with element:
$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', ), ), )); but hydrator strategy never gets called. when remap element text gets called. seems have element being zend\form\element\collection.
actually, can added collections other element. in case there have been several mistakes in using collections correctly:
- did not call
$form->prepare()in view script - did not use
classmethodshydrator while (due debugging), not know why should problem (yet was, missing else)
another possible problem found out:
- your method used
classmethods(e.g.setitemsin case) not callable, zf not call hydrator strategy either
Comments
Post a Comment