Somehow I can't get Form Elements in Zend Framework 2 to be ignored.
All of this doesn't seem to work:
$this->add(array(
'name' => 'submit',
'ignore' => TRUE,
'attributes' => array(
'type' => 'submit',
'value' => 'Go!',
'id' => 'submitbutton',
'ignore' => TRUE
),
'options' => array(
'ignore' => TRUE
)
));
This is how it used to work in Zend Framework1:
//Zend Framework 1
$this->addElement(
'submit',
'login',
array(
'ignore' => true,
'label' => 'Login'
)
);
EDIT:
Why would I need the option "ignore"?
Let's say your form has a submit button. With normal PHP, something like $_POST
will also list your submit button. Zend 1 has the useful options setIgnore($flag)
and getIgnore()
to exclude such elements. $form->getValues()
(after validation) would exclude all elements with flag 'ignore' set to TRUE
. See ZF1 manual.
Check out about inputfilters
My use is like that:
in controller use that
$form = new BasicForm();
$form->setInputFilter(new BasicFilter());
About the filter, you can do this: $factory = new InputFactory();
$this->add($factory->createInput(array(
'name' => 'birthday',
'required' => false,
'allowEmpty' => true,));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With