This is the first time I notice this and it’s surprised me a bit.
I have a zend_form with a simple text element.
$name = new Zend_Form_Element_Text('name');
$name->setLabel('Name');
$this->addElement($name);
The strange thing is that when I submit the form and try to read the value in the form itself (I’m doing some debugging there not in the controller), $name->getValue() doesn’t work but the direct $_POST works.
echo $name->getValue(); //gives blank
echo $_POST['name']; //gives the right value
Is this normal? How does the form not have its values? I thought it’s better to read them with $field->getValue() than to access the $_POST values directly.
The second question is, to read the value in the form, is there a better way than accessing directly from $_POST?
You need to pass the data explicitly to the form, because ZF has no idea where to get it from:
or