ZF-3286: Zend_Form_Element_Multi should behave as enumerated type

Issue Type: Bug Created: 2008-05-18T18:36:07.000+0000 Last Updated: 2008-09-02T10:39:41.000+0000 Status: Resolved Fix version(s): - 1.6.0 (02/Sep/08)

Reporter: Martin Mayer (martin.mayer) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Form

Related issues: - ZF-3563



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:

<pre class="highlight">
$element = new Zend_Form_Element_Select('name');
$element->addMultiOption('foo', "FOO");
$element->addMultiOption('bar', "BAR");

Expected behaviour:

<pre class="highlight">
$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:

<pre class="highlight">
$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.


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.

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.