Zend framework create empty display group and then add element?

You could try with $form->addDisplayGroup(array(), 'exampleGroup') and then get the display group like that: $displayGroup = $form->getDisplayGroup('exampleGroup') and add the elements one by one later with $displayGroup->addElement() or $displayGroup->createElement() You can see more details in the Display Groups documentation EDIT : ZF doesn't allow to add a display group with no elements. The simplest solution could be to create the elements first, put them into an array, and then pass that array to addDisplayGroup It's also possible to instantiate a new Zend_Form_DisplayGroup object and then add it to the form using $form->addDisplayGroups(array($group)) but I doubt if it's more convenient than calling addDisplayGroup() with the elements already created Hope that helps.

You could try with $form->addDisplayGroup(array(), 'exampleGroup'); and then get the display group like that: $displayGroup = $form->getDisplayGroup('exampleGroup'); and add the elements one by one later with $displayGroup->addElement() or $displayGroup->createElement(). You can see more details in the Display Groups documentation. EDIT: ZF doesn't allow to add a display group with no elements.

The simplest solution could be to create the elements first, put them into an array, and then pass that array to addDisplayGroup. It's also possible to instantiate a new Zend_Form_DisplayGroup object and then add it to the form using $form->addDisplayGroups(array($group)), but I doubt if it's more convenient than calling addDisplayGroup() with the elements already created. Hope that helps.

Thanks for your answer dinopmi... I tried before your way but it doeasn't work... It return an exception: No valid elements specified for display group. – Samuele Nov 4 at 9:43 In that case, as @max4ever notes in his comment, it would be easier just to create the elements first and call addDisplayGroup after they are ready... – dinopmi Nov 4 at 9:58.

How about overriding the form's addDisplayGroup($elements, $name) method, adding a dummy element if necessary: class My_Form extends Zend_Form { protected $dummyName = '_myDummy'; public function addDisplayGroup(array $elements, $name) { if (count($elements) == 0){ $elt = new Zend_Form_Element_ $elt->setIgnore(true); $elements = $this->dummyName; } return parent::addDisplayGroup($elements, $name); } public function render(Zend_View_Interface $view = null) { $this->removeElement($this->dummyName); return parent::render($view); } } Then in your form you can now invoke as: $displayGroup = $this->addDisplayGroup(array(), 'myDisplayGroup'); $elt1 = new Zend_Form_Element_Text('myElement1'); $displayGroup->addElement($elt1); $elt2 = new Zend_Form_Element_Text('myElement2'); $displayGroup->addElement($elt2); // etc.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions