Zend Framework

Zend_Dojo_Form_Element_NumberTextBox doesn't allow more than one constraint

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 1.11.6
  • Component/s: Zend_Dojo
  • Labels:
    None

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).

  1. ZF-8453.diff
    25/Apr/11 1:44 PM
    0.5 kB
    Robert Basic
  2. ZF-8453-tests.diff
    25/Apr/11 1:44 PM
    0.7 kB
    Robert Basic

Activity

Hide
Robert Basic added a comment -

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:

$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:

$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.

Show
Robert Basic added a comment - 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:
$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:
$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.
Hide
Robert Basic added a comment -

Patch and tests attached.

Show
Robert Basic added a comment - Patch and tests attached.
Hide
Matthew Weier O'Phinney added a comment -

Patches reviewed and applied to trunk and 1.11 release branch.

Show
Matthew Weier O'Phinney added a comment - Patches reviewed and applied to trunk and 1.11 release branch.
Hide
Robert Basic added a comment -

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

Show
Robert Basic added a comment - Pull request for porting the patch in ZF2 is sent: https://github.com/zendframework/zf2/pull/272

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: