ZF-10281: Zend_Form removes 0 (zero) from the elements index

Issue Type: Bug Created: 2010-08-07T19:16:01.000+0000 Last Updated: 2010-09-02T04:13:59.000+0000 Status: Closed Fix version(s): - 1.10.7 (28/Jul/10)

Reporter: Daniel Lima (yourwebmaker) Assignee: Christian Albrecht (alab) Tags: - Zend_Form

  • Zend_View

Related issues: Attachments:


Zend_Form should not remove the value 0 (zero) from the elements index of subforms.

When I try to create a subform with the following structure:

Zend_Form removes the 0 (zero) from the attributes, thus leaving:

This is bad because some developers use the elements index to map objects to save in the database (e.g. Doctrine).


Posted by Piotr Mlocek (pimlock) on 2010-08-12T06:05:46.000+0000

I couldn't reproduce this behaviour. Could you paste code you are using?

I've tried this example code

<pre class="highlight">
$subform = new Zend_Form_SubForm('subform');

$element = new Zend_Form_Element_Text(array('name' => 'baz'));

and it creates this result

<pre class="highlight">

which is what you expect.

Posted by Daniel Lima (yourwebmaker) on 2010-08-13T13:51:13.000+0000

Sorry for the delay to response your comment

Follow the code:

<pre class="highlight">
//personal info (name, email, dob, etc)
$person = new Zend_Form;
$person->addElement('text', 'name');
//contact form
$contact = new Zend_Form_SubForm;
for ($i = 0; $i <= 3; $i++) {
    //for each contact, i created a subform and append it to contact form
    $contactItem = new Zend_Form_SubForm;
    $contactItem->addElement('text', 'Bar');
    $contact->addSubForm($contactItem, $i);
//so i added the contact form to the main form
$person->addSubForm($contact, 'Contact');

Posted by Piotr Mlocek (pimlock) on 2010-08-16T04:58:32.000+0000

Hmm.. Unfortunatelly I still can't reproduce this behovior :). The code you've provided is producing following html (I'm using ZF 1.10.7):

<pre class="highlight">

So it seems correct.

Here is code I've used to check this: [].

Posted by Daniel Lima (yourwebmaker) on 2010-08-16T11:25:47.000+0000

Men.... you're right! My working copy of ZF is 1.10.6

I related as a 1.10.7 version.

Im so sorry :(

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.