Re: QuickForm: how do you use the same form for EDIT and NEW records?
| From: | Justin Patrin | Date: | Mon, 22 Aug 2005 21:03:45 +0000 |
| Subject: | Re: QuickForm: how do you use the same form for EDIT and NEW records? | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-20526@lists.php.net to get a copy of this message | ||
On 8/22/05, l Burnerheimerton <lburnerheimerton@yahoo.com> wrote:
> I'm almost ready to throw my hands up. I'm not new to
> quickforms but I am creating some new forms and
> running into problems.
>
> If the form is meant to create a new record, I send it
> a URL variable, "newRec". If it's editing a record,
> the form is sent the URL variable, "editRec".
>
> I call:
> $form = new HTML_QuickForm('record', 'POST',
> $_SERVER['PHP_SELF'] . '?' .
> $_SERVER['QUERY_STRING']);
Are you absolutely sure the action is set right? Check the HTML which
is created.
>
> If it's edited, some defaults are set but that's
> really the main difference.
>
> It is blowing up when it processes the form. It wants
> some parameters but not getting them.
>
> Here's what I use to check each parameter:
>
> if (isset($_GET[$param1])) {
> if (strcmp($_GET[$param1], (int)$_GET[$param1]) == 0)
> {
> $arr[$param1] = (int)$_GET[$param1];
> } else { // if it's not a number, log them out of the
> system
> $m = "The URL does not contain the correct
> parameter. ";
> header("Location:
> ErrorPage.php?m=".base64_encode($m));
> exit;
> }
> }
Have you tried outputting these variables to see if they're all #'s?
In addition, it's possible that your query string isn't getting
sent/set properly since the form is POSTed. This *should* work right,
but you never know. If nothing else, just loop through your params and
add them to the form as hidden elements.
>
> Any ideas? If you have SIMPLE examples of forms used
> to process BOTH edit and new records, please post. Thanks!
Sure, I do this with DB_DataObject_FormBuilder all the time.
--
Justin Patrin