HTML quickform question
| From: | php at harper-house dot net | Date: | Sun, 21 Mar 2004 16:36:16 +0000 |
| Subject: | HTML quickform question | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-11418@lists.php.net to get a copy of this message | ||
i have found when using the quickform class with get method that if there are
any variables in the URL (regardless if they are related to the form) the
validate method will try to process any rules and show warnings for failure to
follow the rules.
using the following code: filename=newdata.php
<?php
require_once "HTML/QuickForm.php";
$form = new HTML_QuickForm('dataentry', 'get');
$form->addElement('header', 'MyHeader', 'The Title');
$form->addElement('text', 'tb1', 'data input:');
$buttons[] = &HTML_QuickForm::createElement('reset', 'btnClear',
'Clear');
$buttons[] = &HTML_QuickForm::createElement('submit', 'btnSubmit',
'Submit');
$form->addGroup($buttons, null, null, ' ');
$form->addRule('tb1', 'text input is required','required');
if ($form->validate()) {
$form->freeze();
}
$form->display();
?>
if i use the url localhost\newdata.php
i get exactly what i would expect -> a simple form with an asterick next to the
tb1 textbox
however if the url is localhost\newdata.php?somevar=somevalue
keep in mind 'somevar' has nothing to do with the form - it could be navigation
related,a reference, etc...
i get a form with a warning saying 'data input' is a required field and 'text
input is required'
using the post method does not create this problem but i want to use it with
GET
is there a work around to this?
thank you for your time
matt