Details
Description
Get following code:
$form = new Zend_Form(); $form->addElement(new Zend_Form_Element_Submit('a',array('label'=>'a'))); $form->addElement(new Zend_Form_Element_Submit('b',array('label'=>'b', 'order'=>0))); $form->addElement(new Zend_Form_Element_Submit('c',array('label'=>'c', 'order'=>1))); echo $form;
Only submits 'b' and 'c' are displayed.
Reason:
In Zend/Form.php (@version $Id: Form.php 8996 2008-03-22 16:59:06Z matthew $) there is:
2507: if (array_search($index, $this->_order, true)) { 2508: ++$index; 2509: } 2510: $items[$index] = $key;
In example above, this condition is true for index equal to 0 AND 1, but because there is just if, it is executed only once, so index is set to 1. To *$items[1]* is set submit 'a'. But it is overwritten by submit 'c', because submit 'c' has order set explicitly so no check is performed.
Solution:
2507: while (array_search($index, $this->_order, true)) {
Please evaluate and categorize as necessary.