Playing around with Zend_Form I noticed that when you want to populate a
form, it loops over all form elements and populates them with the available
values.

It loops all elements, including submit buttons, which are unnecessary to
loop over.

When I populate a form, I want it to set default values for all kinds of
fields, but not the submit buttons. (because these values aren't available
in the data-array I provide with the populate method)

Using this populate function, on a form, the values from
$btnSubmit->setValue('submit') get overridden and replaced by null since
there is no key in the data-array which is the same as the submitbutton
object name.

I suggest there should be an extra filter when looping over the different
form elements and only set defaults on text-fields, radio buttons, ... but
NOT on submit buttons (and maybe some other elements). Otherwise these
buttons lose their initailly set value.

Something like this (quick & dirty) in Zend_Form, method setDefault(...):
 if ($element = $this->getElement($name)) {
                
                if(!($element instanceof Zend_Form_Element_Submit))
                {
                        $element->setValue($value);
                }
        } else {...

Same thing for validation check. Should a submit button be validated??

-- 
View this message in context: 
http://www.nabble.com/Zend_Form-populates-all-form-elements--tp16024546s16154p16024546.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to