HTML_QuickForm not getting values from $_POST
| From: | Miguel Telleria de Esteban | Date: | Wed, 15 Jun 2005 15:06:42 +0000 |
| Subject: | HTML_QuickForm not getting values from $_POST | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-19632@lists.php.net to get a copy of this message | ||
Hello there,
SHORT DESCRIPTION
After successfully processing an HTML_QuickForm and obtaining the
submitted values via ->exportValue("valueName"), I create a SECOND
HTML_QuickForm object sharing some element names as the previous one
and hoping that it will get them as well.
The problem
-----------
Even if the element names correspond exactly with the $_POST
variables the posted variables are NOT imported.
Could anyone tell me if I can import those $_POST variables
automatically?
LONGER DESCRIPTION WITH CODE
I am building a sort of wizard[1] with two pages:
- Page 1: Form_1 with 3 values
- Page 2: Form_2 with more values that takes the former 3 as fixed
(i.e. frozen).
[1] I know there is HTML_QuickForm_Controller but I don't envisage yet
to use it.
The problem arrives when Processing the 1st form and Generating the 2nd.
At this stage the code does:
form_1 =& new HTML_QuickForm("form1", "post",
$_SERVER["PHP_SELF"];
I add the elements and rules
form_1->addElement("text", "var1"....)
form_1->addRule(...
...
I call the validation and I get the variable:
if ( !form_1->validate() )
{
// Handle the error
}
variable1 = $form_1->exportValue("var1");
everything goes fine until now.
I create another form:
$form_2 =& new HTML_QuickForm("form2", "post",
$_SERVER["PHP_SELF"];
I add some common elements that have been submitted (otherwise the
previous form would not have been validated).
$form_2->addElement("text", "var1", ... (exactly as above)
THE PROBLEM
When I do
$form_2->display()
or $form_2->exportValue("var1");
WHAT I WOULD LIKE TO ASK?
- Is there a way to automatically import the POST fields in
HTML_QuickForm? (sort of $form->setElementValues)
- How and when are the submitted values present in $_POST imported into
QuickForm? (I have tried to follow the PHP code but I have got
lost).
I am still a newbie in QuickForm terms so I may be missing some
important points.
Any response will be kindly appreciated.
Regards,
Miguel Telleria