Issues

ZF-7235: FormErrors not taking Zend_Form setIsArray into account

Issue Type: Bug Created: 2009-07-10T00:24:30.000+0000 Last Updated: 2010-05-24T09:04:34.000+0000 Status: Resolved Fix version(s): Reporter: Marcel van Brakel (fiber_nl) Assignee: Christian Albrecht (alab) Tags: - Zend_Form

Related issues: Attachments:

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

Posted by Nicholas Calugar (njcalugar) on 2010-02-27T14:28:32.000+0000

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

<pre class="highlight">
<?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(''));

Posted by Christian Albrecht (alab) on 2010-05-24T09:04:33.000+0000

Fixed in trunk r22270 and merged into 1.10 release branch

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