ZF-11718: Zend_Form::_sort() removes items from _order when using both ordered and unordered items
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).
<?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
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