ZF-10683: Zend_Form does not handle multiple DisplayGroups from xml file properly
Description
Zend_Form's function setOptions is not capable handling multiple displayGroups when the form is created from a xml file. I used Zend_Config_Xml to access the form options and the whole form is set up like this. This is how the option representation looks like for one and two displaygroups coming from the xml:
one group
array(1) {
["DisplayGroup"] => array(3) {
["name"] => string(7) "contact"
["elements"] => array(4) {
["ElementName1"] => string(9) "firstname"
["ElementName2"] => string(8) "lastname"
["ElementName3"] => string(5) "email"
["ElementName4"] => string(6) "mobile"
}
["options"] => array(1) {
["legend"] => string(15) "Contact Details"
}
}
}
two groups
array(1) {
["DisplayGroup"] => array(2) {
[0] => array(3) {
["name"] => string(7) "contact"
["elements"] => array(4) {
["ElementName1"] => string(9) "firstname"
["ElementName2"] => string(8) "lastname"
["ElementName3"] => string(5) "email"
["ElementName4"] => string(6) "mobile"
}
["options"] => array(1) {
["legend"] => string(15) "Contact Details"
}
}
[1] => array(3) {
["name"] => string(5) "login"
["elements"] => array(1) {
["ElementName1"] => string(8) "username"
}
["options"] => array(1) {
["legend"] => string(13) "Login Details"
}
}
}
}
I created a little patch for Zend_Form which handles the displaygroups properly. The bug exists in 1.11 and 1.10.8 and probably in earlier versions as well.
Comments
Posted by Sebastian (sebmill) on 2010-11-14T20:35:38.000+0000
Patch:
Eclipse Workspace Patch 1.0
P Zend_Framework-current
Index: library/Zend/Form.php
--- library/Zend/Form.php (revision 23334) +++ library/Zend/Form.php (working copy) @@ -343,6 +343,17 @@ unset($options['displayGroupDecorators']); }
Posted by Ramon Henrique Ornelas (ramon) on 2010-11-27T05:00:39.000+0000
I believe that this is improvement and not a bug. Correct me if I'm wrong