Issues

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

Implemented in trunk r22309 and merged into 1.10 release

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

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()) { ... }

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

Christian -- awesome! Yeah, the verbiage had me confused, so I wanted to double-check.