ZF-7235: FormErrors not taking Zend_Form setIsArray into account

Description

FormErrors function "_recurseForm" does not check for the setting "isArray" on the supplied zend form.

When using subforms the first if statement (ln. 372) is triggered. This behaviour is also wanted when using your main form as isArray. Because this makes the array multidimensional.

This is leading to a non functional FormErrors decorator. Because it will never get the errors into the foreach loop on ln 383.

I momentarily fixed it by addind "|| $form->isArray()" to the if statement on ln 372. Don't know if that is the correct fix but i thought i should share

Comments

The code below shows that the FormErrors decorator produces no output if the forms isArray flag is true.


<?php
require_once 'Zend/Debug.php';
require_once 'Zend/Form.php';
require_once 'Zend/Form/Decorator/FormErrors.php';
require_once 'Zend/Form/Element/Select.php';
require_once 'Zend/View.php';

$form = new Zend_Form(
    array(
        'decorators'=>array(
            new Zend_Form_Decorator_FormErrors(),
        ),
    )
);

$form->setView(new Zend_View());

$form->addElement(new Zend_Form_Element_Select(array('name'=>'test', 'multiOptions'=>array(0,1))));

Zend_Debug::dump($form->isValid(array('test'=>2)));

Zend_Debug::dump($form->getErrors());

$formErrorsDecorator = $form->getDecorator('FormErrors');
$formErrorsDecorator->setElement($form);

Zend_Debug::dump($formErrorsDecorator->render(''));

$form->setIsArray(true);
Zend_Debug::dump($formErrorsDecorator->render(''));

Fixed in trunk r22270 and merged into 1.10 release branch