Problem retrieving values from Zend_Form_SubForms - no values returned
Posted
by anu iyer
on Stack Overflow
See other posts from Stack Overflow
or by anu iyer
Published on 2010-01-07T16:34:26Z
Indexed on
2010/03/18
3:01 UTC
Read the original article
Hit count: 440
zend-form-sub-form
|zend-form
I have a Zend_Form that has 4 or more subforms.
/** Code Snippet **/ $bigForm = new Zend_Form();
$littleForm1 = new Form_LittleForm1();
$littleForm1->setMethod('post');
$littleForm2 = new Form_LittleForm2();
$littleForm2->setMethod('post');
$bigForm->addSubForm($littleForm1,'littleForm1',0);
$bigForm->addSubForm($littleForm2,'littleForm2',0);
On clicking the 'submit' button, I'm trying to print out the values entered into the forms, like so:
/** Code snippet, currently not validating, just printing **/
if($this->_request->getPost()){ $formData = array();
foreach($bigForm->getSubForms() as $subForm){
$formData = array_merge($formData, $subForm->getValues());
}
/* Testing */
echo "<pre>";
print_r($formData);
echo "</pre>";
}
The end result is that - all the elements in the form do get printed, but the values entered before posting the form don't get printed.
Any thoughts are appreciated...I have run around circles working on this!
Thanks in advance!
© Stack Overflow or respective owner