Issues

ZF-11718: Zend_Form::_sort() removes items from _order when using both ordered and unordered items

Issue Type: Bug Created: 2011-09-02T14:04:48.000+0000 Last Updated: 2011-09-02T14:04:48.000+0000 Status: Open Fix version(s): Reporter: Petri Mahanen (pmahanen) Assignee: Christian Albrecht (alab) Tags: - Zend_Form

Related issues: Attachments:

Description

Zend_Form::_sort() may remove items from the internal _order, causing eg. some form elements to not be rendered.

This bug may present itself when both ordered and unordered items are used.

Reproduction

This example shows two bugs (Element overwrites DisplayGroup, and vice versa).

<pre class="highlight">
<?php

require "Zend/Form.php";

class TestForm extends Zend_Form
{
    public function init()
    {
        $this->addElement('text', 'alpha');
        $this->addDisplayGroup(array('alpha'), 'group-alpha');
        $this->getDisplayGroup('group-alpha')->setOrder(0);
        
        $this->addElement('text', 'beta');
        
        var_dump($this->_order);

        $this->_sort();
        
        var_dump($this->_order);



        $this->clearElements()
             ->clearDisplayGroups();

        $this->addElement('text', 'alpha');

        $this->addElement('text', 'beta');
        $this->addDisplayGroup(array('beta'), 'group-beta');
        $this->getDisplayGroup('group-beta')->setOrder(0);

        var_dump($this->_order);

        $this->_sort();

        var_dump($this->_order);
    }
}

new TestForm();

Output

<pre class="literal">
array(2) {
  ["group-alpha"]=>
  NULL
  ["beta"]=>
  NULL
}
array(1) {
  ["beta"]=>
  int(0)
}
array(2) {
  ["alpha"]=>
  NULL
  ["group-beta"]=>
  NULL
}
array(1) {
  ["group-beta"]=>
  int(0)
}

Comments

No comments to display

Have you found an issue?

See the Overview section for more details.

Copyright

© 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.

Contacts