Details
Description
While trying to setup DisplayGroups in an xml configuration file (ordered by tag name) I discovered, that because I defined it above the elements-tag it wouldn't work. Would be nice if Zend_Form could handle the options in an appropriate order.
XML-File:
<?xml version="1.0" encoding="UTF-8"?> <forms> <sitearea> <test> <Elements> <ElementName1> <type>text</type> <name>ElementName1</name> <options> <label>Label 1</label> </options> </ElementName1> <ElementName2> <type>text</type> <name>ElementName2</name> <options> <label>Label 2</label> </options> </ElementName2> <ElementName3> <type>text</type> <name>ElementName3</name> <options> <label>Label 3</label> </options> </ElementName3> <ElementName4> <type>text</type> <name>ElementName4</name> <options> <label>Label 4</label> </options> </ElementName4> </Elements> <Legend>Form 1</Legend> <Method>post</Method> <DisplayGroups> <DisplayGroup> <Elements> <ElementName1>ElementName1</ElementName1> <ElementName2>ElementName2</ElementName2> </Elements> <Options> <Name>login</Name> <label>Test</label> <Legend>Form 1</Legend> </Options> </DisplayGroup> </DisplayGroups> <DefaultDisplayGroupClass> <fieldset> <decorator>Fieldset</decorator> <options></options> </fieldset> </DefaultDisplayGroupClass> </test> <test2> <DefaultDisplayGroupClass> <fieldset> <decorator>Fieldset</decorator> <options></options> </fieldset> </DefaultDisplayGroupClass> <DisplayGroups> <DisplayGroup> <Elements> <ElementName1>ElementName1</ElementName1> <ElementName2>ElementName2</ElementName2> </Elements> <Options> <Name>login</Name> <label>Test</label> <Legend>Form 1</Legend> </Options> </DisplayGroup> </DisplayGroups> <Elements> <ElementName1> <type>text</type> <name>ElementName1</name> <options> <label>Label 1</label> </options> </ElementName1> <ElementName2> <type>text</type> <name>ElementName2</name> <options> <label>Label 2</label> </options> </ElementName2> <ElementName3> <type>text</type> <name>ElementName3</name> <options> <label>Label 3</label> </options> </ElementName3> <ElementName4> <type>text</type> <name>ElementName4</name> <options> <label>Label 4</label> </options> </ElementName4> </Elements> <Legend>Form 1</Legend> <Method>post</Method> </test2> </sitearea> </forms>
Controller:
$config = new Zend_Config_Xml(BASE_PATH . 'application/modules/ecrf/config/test.xml', 'sitearea', true); $form = new Zend_Form($config->test); $form2 = new Zend_Form($config->test2); $this->view->form = $form; $this->view->form2 = $form2;
If you look at the xml file you'll notice that <test> and <test2> have the same options. <test> works fine but <test2> doesn't work because of the different order. The error that occures starts with: Fatal error: Uncaught exception 'Zend_Form_Exception' with message 'No valid elements specified for display group' in D:\xampp\htdocs\projekte\zend\library\Zend\Form.php:1439 ...
Hope, you can now reproduce it. The snapshot used is ZendFramework-20080501-9348-en
Please evaluate and categorize as necessary.