ZF-10731: addDisplayGroup() should automatically call addElement()
Description
When always using fieldsets with labels, it's very annoying to always use this procedure:
$lenDateFrom = new Zend_Form_Element_Text('lenDateFrom'); $lenDateFrom->setValue($dateFrom); $lenDateFrom->setRequired(); $this->addElement($lenDateFrom);
...more Elements....
$this->addDisplayGroup(array('lenDateFrom', '....', '...', ..), 'name', array('legend' => 'mainData') );
Because that is to much work, I created an wrapper, which would maybe be fine in Zend_Form to:
How does this wrapper works? See example in attached file.
What does the wrapper do? call $this->addElement() call/create addDisplayGroup
How is the call now? $lenDateFrom = new Zend_Form_Element_Text('lenDateFrom'); $lenDateFrom->setValue($dateFrom); $lenDateFrom->setRequired(); $this->addFieldset($lenDateFrom, 'mainData');
At the end of the Form renderFieldsets() is called.
It would need some modifications to be more abstract, but maybe the code snippet is usefull.
Comments
Posted by Martin Keckeis (thadafinser) on 2010-11-23T07:35:32.000+0000
Example
Posted by Kai Uwe (kaiuwe) on 2010-11-23T09:39:02.000+0000
@Martin Keckeis Please use code tags! Thanks.
Here's is my suggestion:
Posted by Richard Tuin (richardtuin) on 2010-11-23T13:39:20.000+0000
This issue is related to ZF-10491.
Posted by Richard Tuin (richardtuin) on 2010-11-27T05:53:00.000+0000
The attached patch automatically adds the {{Zend_Form_Element}}'s in $element to the form. Therefore calling {{Zend_Form::addElement}} won't be mandatory anymore.
Also, unit tests are included, as well as my fix to ZF-10734 (which isn't committed at this moment)
Posted by Ramon Henrique Ornelas (ramon) on 2011-01-01T09:54:54.000+0000
Fixed r23603 in trunk merged to release branch 1.11 r23604 - thanks.