Zend Framework

Zend_Config_Xml passed to Zend_Form needs to be in correct order

Details

  • Type: Improvement Improvement
  • Status: Resolved Resolved
  • Priority: Trivial Trivial
  • Resolution: Cannot Reproduce
  • Affects Version/s: 1.5.1
  • Fix Version/s: 1.5.2
  • Component/s: Zend_Form
  • Labels:
    None
  • Fix Version Priority:
    Should Have

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

Activity

Hide
Wil Sinclair added a comment -

Please evaluate and categorize as necessary.

Show
Wil Sinclair added a comment - Please evaluate and categorize as necessary.
Hide
Matthew Weier O'Phinney added a comment -

Scheduling for next mini release

Show
Matthew Weier O'Phinney added a comment - Scheduling for next mini release
Hide
Matthew Weier O'Phinney added a comment -

Added a test to the suite showing to reproduce this (see r9380), but the test continued to pass. If you still experience the issue, please re-open, but be sure to paste in a fully reproducible case when doing so.

Show
Matthew Weier O'Phinney added a comment - Added a test to the suite showing to reproduce this (see r9380), but the test continued to pass. If you still experience the issue, please re-open, but be sure to paste in a fully reproducible case when doing so.
Hide
Tobias Schifftner added a comment -

Added example for reproduction

Show
Tobias Schifftner added a comment - Added example for reproduction

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved:

Time Tracking

Estimated:
15m
Original Estimate - 15 minutes
Remaining:
15m
Remaining Estimate - 15 minutes
Logged:
Not Specified
Time Spent - Not Specified