ZF-10259: CLONE -"max" option of Zend_Form StringLength validator considered as "min" option when "min" option is omitted

Issue Type: Bug Created: 2010-08-03T11:14:26.000+0000 Last Updated: 2010-11-22T11:46:23.000+0000 Status: Resolved Fix version(s): - 1.10.8 (25/Aug/10)

Reporter: Tim Stiles (monkeyt) Assignee: Thomas Weidner (thomas) Tags: - Zend_Form

Related issues: - ZF-6623



When you create a form element from .ini file, and add a StringLength validator to your element with a .max option but without .min option, then .max is wrongly interpreted as .min.


<pre class="highlight">
user_details.elements.firstname.options.validators.strlen.validator = "StringLength"
user_details.elements.firstname.options.validators.strlen.options.max = "30"

Let's say I input "foo" as firstname Actual result:{quote} - form does not validate - following error message is displayed: 'foo' is less than 30 characters long {quote} Expected result:{quote} - form should validate - no error should be displayed {quote} NOTE: this bug may impact other validators as well. Problem comes from Zend_Form_Element::_loadValidator() ``` $validator['options'] is passed to constructor without taking into consideration options name<

Temporary workaround: - always specify a min length as well (set it to 0)


Posted by Tim Stiles (monkeyt) on 2010-08-03T11:16:23.000+0000

Witnessing this EXACT same behavior using both 1.10.5 and 1.10.7

Same workaround temporarily resolves problem.

Posted by Thomas Weidner (thomas) on 2010-08-03T11:36:51.000+0000

Unable to reproduce. Please give additional information for reproduction.

The following test does not fail (but should according to your description):

<pre class="highlight">
    public function testValidatorsGivenArrayKeysOnValidation2()
        $firstname = new Zend_Form_Element('firstname');
        $firstname->addValidator('StringLength', true, array('max' => 30));
        $form = new Zend_Form(array('elements' => array($firstname)));
        $this->assertTrue($form->isValid(array('firstname' => 'abcde')));

Posted by Tim Stiles (monkeyt) on 2010-08-03T12:15:38.000+0000

My mistake. The configuration of this site accidentally pointed Zend references to a copy of the 1.9.2 Framework instead of the current release.

Thank you for your help.

Posted by Thomas Weidner (thomas) on 2010-08-03T12:21:58.000+0000

Closing as non-issue

Posted by Thomas Weidner (thomas) on 2010-11-22T11:46:23.000+0000

Correct fix version as it has been deleted unintentionally by another user

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.