Re: HTML_QuickForm: form fields as array problem
| From: | Bertrand Mansion | Date: | Mon, 30 Dec 2002 17:07:56 +0000 |
| Subject: | Re: HTML_QuickForm: form fields as array problem | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-11964@lists.php.net to get a copy of this message | ||
Hi,
This is not working in QuickForm. Use groups instead if you want this kind
of notation with brackets. Jason Rust once wrote a formizeArray method but I
don't have it under the hand. You might want to ask him directly.
I can't help more, I will be very busy till the end of January.
Good luck,
Bertrand Mansion
Mamasam
<jeroen@terena.nl> wrote :
> Hi,
>
> 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();
> }
> ?>