Zend Framework

Ids not updating in cloned sub forms

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 1.6.0
  • Component/s: Zend_Form
  • Labels:
    None
  • Fix Version Priority:
    Must Have

Description

When cloning a single sub form to attach repeatedly in Zend_Form, the names update, but the ids do not. As an example:

$subForm = new Zend_Form_SubForm();
$subForm->addElement('text', 'foo');

$form = new Zend_Form(array('action' => '/foo/bar', 'method' => 'post'));

for ($i = 1; $i < 4; ++$i) {
    $name = 'sub' . $i;
    $sub  = clone $subForm;
    $form->addSubForm($sub, $name);
}

echo $form->render(new Zend_View);

This will result in the output:

<form enctype="application/x-www-form-urlencoded" action="/foo/bar" method="post" id=""><dl class="zend_form">
<dt>&nbsp;</dt><dd><fieldset id="sub1-fieldset"><dl>
<dt>&nbsp;</dt>
<dd>
<input type="text" name="sub1[foo]" id="sub1-foo" value=""></dd></dl></fieldset></dd>
<dt>&nbsp;</dt><dd><fieldset id="sub2-fieldset"><dl>
<dt>&nbsp;</dt>
<dd>
<input type="text" name="sub2[foo]" id="sub1-foo" value=""></dd></dl></fieldset></dd>
<dt>&nbsp;</dt><dd><fieldset id="sub3-fieldset"><dl>
<dt>&nbsp;</dt>
<dd>
<input type="text" name="sub3[foo]" id="sub1-foo" value=""></dd></dl></fieldset></dd></dl></form>

As can be seen, the names are correct, but the ids are not.

Activity

Hide
Matthew Weier O'Phinney added a comment -

The issue was that cloning was not cloning the elements, display groups, or sub forms. This is now resolved in trunk and 1.6 release branch.

Show
Matthew Weier O'Phinney added a comment - The issue was that cloning was not cloning the elements, display groups, or sub forms. This is now resolved in trunk and 1.6 release branch.
Hide
Wil Sinclair added a comment -

Updating for the 1.6.0 release.

Show
Wil Sinclair added a comment - Updating for the 1.6.0 release.

People

Vote (0)
Watch (0)

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