ZF-3286: Zend_Form_Element_Multi should behave as enumerated type
Description
Actualy I'm not sure if this is bug or feature, but I'd expect all elements extending Zend_Form_Element_Multi to work as enums.
Having this element:
$element = new Zend_Form_Element_Select('name');
$element->addMultiOption('foo', "FOO");
$element->addMultiOption('bar', "BAR");
Expected behaviour:
$element->isValid('foo'); // returns true
$element->getValue(); // returns "foo"
But I was a bit surprised that a value which is unlisted can be accepted and returned:
$element->isValid('unlisted-value'); // returns true
$element->getValue(); // returns "unlisted-value"
I know this can be solved by adding InArray validator. But I would expect it's (probably the main) purpose and default behaviour of these elements not to let through unavailable options. If this behaviour is realy so intended, I think there should be at least warning in manual that it's upon to developer to provide the check manually. This relates to Select, MultiSelect, MultiCheckbox and Radio elements.
Comments
Posted by Wil Sinclair (wil) on 2008-06-01T15:43:29.000+0000
Please evaluate and categorize as necessary.
Posted by Matthew Weier O'Phinney (matthew) on 2008-08-04T13:26:23.000+0000
Behavior added to trunk and 1.6 release branch. New flag, 'registerInArrayValidator' allows you to disable the functionality as desired.
Also did the same for the Dojo form elements.
Posted by Wil Sinclair (wil) on 2008-09-02T10:39:41.000+0000
Updating for the 1.6.0 release.