| Justin Patrin 2005-10-24, 9:56 pm |
| On 10/24/05, l Burnerheimerton <lburnerheimerton@yahoo.com> wrote:
> I want to include my QuickForm snippets as "includes"
> in a page controller model. Sample code below.
>
> A link might go to:
> www.site.com/index.php?act=3Dnext_page
>
> When they click on that link, the form displays
> properly. But when the user clicks to submit the
> button, it takes the "act=3Dnext_page" out of the URL so
> it destroys what I am trying to do with the page
> controller.
>
> How can I get the form to process AND 1)redisplay with
> errors if it does not pass validation; 2)go back to
> index.php?act=3Dnext_page if it does pass validation?
>
> Thanks.
>
>
> index.php:
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D[col
or=darkred]
> <html>
> <head>
> <meta http-equiv=3D"Content-Type" content=3D"text/html;
> charset=3Diso-8859-1">
> </head>
> <body>
> <p>Welcome</p>
> <p>Click <a href=3D"index.php?act=3Dnext_page">here</a>
> </p>
> <?php
> if (isset($_GET['act'])) {
> switch ($_GET['act']) {
> case "next_page":
> require_once 'form.php';
> }
> }
> ?>
> </body>
> </html>
>
>
> form.php:
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=[/color]
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D[col
or=darkred]
> <?php
> require_once "HTML/QuickForm.php";
> $form =3D new HTML_QuickForm('newCAR', 'GET',
> $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING']
> . '&',NULL,NULL,true);[/color]
You're sending your form via GET and have GET params in your action.
I'm not sure if web browsers know how to deal with this properly. I
suggest not putting any query string in the action and instead making
those variables hidden values in your form.
> $form->addElement('header', 'MyHeader', 'Testing
> QuickForm');
> $form->addElement('text', 'MyTextBox', 'What is your
> name?');
> $form->addElement('reset', 'btnClear', 'Clear');
> $form->addElement('submit', 'btnSubmit', 'Submit');
> if ($form->validate()) {
> $form->freeze();
> // I know I would add redirect command here is it
> passes validation
> }
> $form->display();
> ?>
>
--
Justin Patrin
|