Issue Type: Bug Created: 2011-01-17T08:09:34.000+0000 Last Updated: 2011-09-22T19:21:46.000+0000 Status: Resolved Fix version(s): Reporter: Halbach Media (halbach_media) Assignee: Richard Tuin (richardtuin) Tags: - Zend_Form
Related issues: - ZF-11729
If you create a Zend Form and add an Element with an id (name) like 'form_data_id234'. You can easily add this form to a displaygroup using addDisplayGroup().
But if your elements id is too long it will be added to the display group and remains in the "main" form too. (Outside of the desired display group.) So this element exists twice in a form. First it appears in the display group and also outside of the group but inside the form.
As the fields name is identical, this would raise a logical validation error... (You could never be sure which field value will be used as the correct input field value.)
Here are some example names which are too long and will appear twice in the form: _form_personDetail_communication_COM_4c808f1c19cb1831254439-element _form_personDetail_communication_COM_4c808f1c19cb1831254439-element
I stumbled upon this error afterI updated from 1.10.7 to 1.11.2. In 1.10.7 everythings works as expected.
Posted by Halbach Media (halbach_media) on 2011-01-18T01:07:32.000+0000
The duplicated fields also appear when you are trying to manually set a field name to something like
ZF removes the brackets but you will have the fields twice inside your form too.
I assume the fields-id is used as a key to access the field anytime later. So this key might be processed (removing brackets, change length, etc.) will be executed but the "original" id remains untouched anywhere in the form elements config data.
Posted by Richard Tuin (richardtuin) on 2011-01-20T12:53:06.000+0000
I was not able to reproduce this issue. Can you provide a code sample that reproduces this issue?
Posted by Kai Uwe (kaiuwe) on 2011-01-24T00:26:59.000+0000
I think, it is not a problem of length, but a problem with the hyphen in the name:
<pre class="highlight"> // Form $form = new Zend_Form(); $form->setDecorators(array( 'FormElements', 'Form', )); // Elements $form->addElement('text', 'first-name', array( 'label' => 'First name', 'decorators' => array( 'ViewHelper', 'Label', ), )); $form->addElement('text', 'lastname', array( 'label' => 'Last name', 'decorators' => array( 'ViewHelper', 'Label', ), )); // Display group $form->addDisplayGroup(array('first-name', 'lastname'), 'name', array( 'decorators' => array( 'FormElements', 'Fieldset', ), )); echo $form->render(new Zend_View()); <pre class="highlight"> First name First name Last name
Posted by Richard Tuin (richardtuin) on 2011-09-22T19:21:46.000+0000
Issue ZF-11729 is a duplicate of this and is resolved/fixed. Tests inspected, no need to add additional unit tests for this specific issue.
Have you found an issue?
See the Overview section for more details.