Issues

ZF-2862: Zend_Form validator chain does not keep break on chain when NotEmpty added for required elements

Issue Type: Bug Created: 2008-03-11T11:47:37.000+0000 Last Updated: 2008-03-21T17:30:30.000+0000 Status: Resolved Fix version(s): - 1.5.0 (17/Mar/08)

Reporter: Matthew Weier O'Phinney (matthew) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Form

Related issues: Attachments:

Description

Reproduce code:

<pre class="highlight">
$username = new Zend_Form_Element_Text('username');
$username->addValidator('stringLength', true, array(5, 20))
         ->addValidator('regex', true, array('/^[a-zA-Z0-9_]*$/'))
         ->addFilter('StringToLower')
         ->setRequired(true);
$form = new Zend_Form();
$form->addElement($username);

$form->isValid(array('username' => '#'));
echo var_export( $form->getMessages(), 1), "\n\n";

Expected results:

<pre class="highlight">
array (
  'username' =>
  array (
    'stringLengthTooShort' => '\'#\' is less than 5 characters long',
  ),
)

Actual result:

<pre class="highlight">
array (
  'username' => 
  array (
    'stringLengthTooShort' => '\'#\' is less than 5 characters long',
    'regexNotMatch' => '\'#\' does not match against pattern \'/^[a-zA-Z0-9_]*$/\'',
  ),
)

Comments

Posted by Matthew Weier O'Phinney (matthew) on 2008-03-11T14:56:53.000+0000

Fixed in trunk and 1.5 release branch. addValidator() was overwriting the zfBreakChainOnFailure flag on the second pass.

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