ZF-9896: Zend_Form::getValidValues(): dont't return values for ignored elements
Description
<?php
$form = new Zend_Form();
$form->addElement(new Zend_Form_Element_Text('integer', array(
'label' => 'Integer value',
'required' => true,
'filters' => array('Int'),
'validators'=> array(
array('GreaterThan', false, array('min' => 0))
)
)));
$form->addElement(new Zend_Form_Element_Submit('submit', array(
'label' => 'Submit form',
'required'=> false,
'ignore'=> true
)));
$validValues = $form->getValidValues(array(
'integer' => '2z',
'submit' => 'Submit form'
));
?>
expect: Array ( [integer] => 2 ) but got: Array ( [integer] => 2 [submit] => Submit form )
Comments
Posted by Christian Albrecht (alab) on 2010-05-27T03:15:01.000+0000
Implemented in trunk r22309 and merged into 1.10 release
Posted by Matthew Weier O'Phinney (matthew) on 2010-05-27T05:59:29.000+0000
Actually, Christian, please revert the patch.
When an element is marked as "ignore", the intention is that getValues() and getValidValues() should not return that element -- that's the whole purpose of the "ignore" flag in the first place. The idea is that for elements that have no purpose in your model -- such as submit and reset buttons -- you can flag them as "ignore" so that the values will not be aggregated.
If you want the value, simply don't flag it to "ignore".
Posted by Alexey Pakhomov (alpaxo) on 2010-05-27T07:01:12.000+0000
Yes, Matthew. Exactly same behavior I expect. But in recent release "ignore" flag is ignored. As I can see in trunk this was fixed with checking for
if (!$element->getIgnore()) { ... }
Posted by Christian Albrecht (alab) on 2010-05-27T07:32:47.000+0000
Matthew, maybe that was due to my not so perfect english - the commit message was make ... not collect ...
This functionality was either lost somewhere at the bughunt in april, or wasn't implemented in getValidValues() before.
So now after the patch applied the behaviour is exactly what you want it to be :D
Posted by Matthew Weier O'Phinney (matthew) on 2010-05-27T08:48:54.000+0000
Christian -- awesome! Yeah, the verbiage had me confused, so I wanted to double-check.