Quickform - using HTML arrays for element names doesn't work?
| From: | Jeroen Houben | Date: | Mon, 30 Dec 2002 12:36:04 +0000 |
| Subject: | Quickform - using HTML arrays for element names doesn't work? | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-3110@lists.php.net to get a copy of this message | ||
Hi,
I posted this message a while ago on the PEAR dev list but I got 0 replies. If
you also use PEAR::Quickform, please try the code below to see if you get the
same error.
Defining elements like:
$form->addElement('text', 'input[textbox]', 'normal tb:');
doesn't seem to work properly.
$form->addElement('text', 'textbox', 'normal tb:');
however does work.
Run the two examples below and only leave the *required field blank. Only in
the 2nd example will the the script "remember" what the user put in the 2nd
textbox. Am I doing something wrong or is this a bug?
Thanks
Jeroen
<?php
// #1 doesn't work
require_once ("HTML/QuickForm.php");
$form = new HTML_QuickForm('frmTest', 'POST');
$form->addElement('text', 'input[req_textbox]', 'required tb:');
$form->addElement('text', 'input[textbox]', 'normal tb:');
$form->addElement('submit', 'isubTest', 'Test Submit');
// Adds some validation rules
$form->addRule('input[req_textbox]', 'this is a required field',
'required');
// Tries to validate the form
if ($form->validate()) {
// Form is validated, then processes the data
$form->freeze();
$form->process();
echo "\n<HR>\n";
} else {
$form->display();
}
?>
to
<?php
// #2 does work
require_once ("HTML/QuickForm.php");
$form = new HTML_QuickForm('frmTest', 'POST');
$form->addElement('text', 'req_textbox', 'required tb:');
$form->addElement('text', 'textbox', 'normal tb:');
$form->addElement('submit', 'isubTest', 'Test Submit');
// Adds some validation rules
$form->addRule('req_textbox', 'this is a required field',
'required');
// Tries to validate the form
if ($form->validate()) {
// Form is validated, then processes the data
$form->freeze();
$form->process();
echo "\n<HR>\n";
} else {
$form->display();
}
?>