views:

28

answers:

1

i learnt that i can set the ignore flag on a Zend_Form_Element so that its ignored when getting values etc.

i have

$this->addElement('submit', 'btnLogin', array(
    'label' => 'Login',
    'ignore' => true
));

but when i do

foreach ($this->getElements() as $elem) {
    echo $elem->getName() . "<br />";
}

it stills includes the btnLogin

+1  A: 

The ignore-flag will only ensure that the form element does not get a name-attribute effectively removing it from the posted form data is not included when retrieving the form values on the form level ($form->getValues()). You won't get the element's value when doing e.g.:

foreach ($form->getValues() as $name => $value) {
    // ...
}
Stefan Gehrig
hmm i am still getting `<input type="submit" value="Login" id="btnLogin" name="btnLogin">`
jiewmeng
You're right... I mixed up the `ignore`-handling in Zend Framework and ExtJS - stupid... `ignore` will only ensure that the element's values is not included when retrieving the data on the form level (`$form->getValues()`). I'll adjust my answer accordingly.
Stefan Gehrig