Issues

ZF-8453: Zend_Dojo_Form_Element_NumberTextBox doesn't allow more than one constraint

Issue Type: Bug Created: 2009-12-03T03:47:30.000+0000 Last Updated: 2011-07-28T15:29:15.000+0000 Status: Resolved Fix version(s): - 1.11.6 (05/May/11)

Reporter: Nick Davies (nick.davies) Assignee: Robert Basic (robertbasic) Tags: - Zend_Dojo

Related issues: Attachments: - ZF-8453-tests.diff

Description

It's not possible to use setPattern then subsequently setConstraint on a Zend_Dojo_Form_Element_NumberTextBox.

setPattern uses set constraint to add a pattern as a constraint then setConstraint overwrites the previous setPattern(setConstraint).

Comments

Posted by Robert Basic (robertbasic) on 2011-04-25T13:44:11.000+0000

Actually, this is not related to specifically to Zend_Dojo_Form_Element_NumberTextBox but to Zend_Dojo_Form_Element_ValidationTextBox

To describe more closely the issue, a few examples:

<pre class="highlight">
$this->addElement(
    'NumberTextBox',
    'number',
    array(
        'label' => 'Number',
        'constraints' => array(
            'places' => '6'
        ),
        'pattern' => '0.######',
        'locale' => 'en'
    )
);

Will generate the the constraints, as expected, for "places", "pattern" and "locale".

But, on the other hand:

<pre class="highlight">
$this->addElement(
    'NumberTextBox',
    'number',
    array(
        'label' => 'Number',
        'pattern' => '0.######',
        'locale' => 'en',
        'constraints' => array(
            'places' => '6'
        )
    )
);

will generate constraints only for the "places".

Even if the method name is setConstraints, what it is actually doing is adding constraints, so the second example should generate the same result as the first one.

Posted by Robert Basic (robertbasic) on 2011-04-25T13:44:49.000+0000

Patch and tests attached.

Posted by Matthew Weier O'Phinney (matthew) on 2011-05-02T19:28:58.000+0000

Patches reviewed and applied to trunk and 1.11 release branch.

Posted by Robert Basic (robertbasic) on 2011-07-28T15:29:15.000+0000

Pull request for porting the patch in ZF2 is sent: https://github.com/zendframework/zf2/pull/272

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