0

A Zend_Form like this:

class Application_Form_Registration extends Zend_Form
{

    public function init()
    {
        /* Form Elements & Other Definitions Here ... */
        $$this->setMethod('post');

        //first name
        $this->addElement('text', 'email', array(
            'label'         => 'First name',
            'required'      => true,
            'filters'       => array('StringTrim'),
        ));

        //last name
        $this->addElement('text', 'lastname', array(
            'label'         => 'Last name', 
            'required'      => true,
            'filters'       => array('StringTrim')
        ));

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

        $this->addElement('hash', 'csrf', array(
            'ignore'    => true,
        ));
    }


}

I read through the ZF1 1.12 API and reference document, but I can't find the meaning of the flag "ignore" in the Zend_Form::addElement() configure options.

The api doc is just this: enter image description here

Surely I googled it and find it but this is not the way to work. How to I find the meaning of certain specific stuff. I don't suppose that I need to read the source code?

Just take this addElement() as an example, am I missing somewhere to look further? Nothing in Zend_Config class that I can find about ignore flag either.

jnersn
  • 384
  • 1
  • 3
  • 14
Hao
  • 6,291
  • 9
  • 39
  • 88

2 Answers2

0

As I know ignore flag defines if form values ($form->getValues()) will contain element value. If ignore is set to true for some element than form values ($form->getValues()) will not contain this element value.

Max P.
  • 5,579
  • 2
  • 13
  • 32
  • Thanks, but actually i was curious to know how you learn about this. Like I explained in the question, I don't know where to look to find such information. – Hao Mar 14 '16 at 03:28
  • > I don't know where to look to find such information. - on stackoverflow :) – Max P. Mar 14 '16 at 08:00
0

ZF Documentation can be...lacking sometimes. The API docs for the ignore flag state:

getIgnore( ) : bool Get ignore flag (used when retrieving values at form level)

Which hints that the ignore flag has something to do with the behavior of Zend_Form GetValues() but it's not really spelled out.

In these cases I like to go straight to the source code so I can see for myself:

public function getValues($supressArrayNotation = false)
{
    ...
    foreach ($this->getElements() as $key => $element) {
        if (!$element->getIgnore()) {
    ...
}

You can see that the getValues() function in Zend_Form will check the ignore flag on each element before adding the value to the return array. If the flag is true, the value won't be included.

ski4404
  • 311
  • 1
  • 6