Re: QuickForm2 validation
| From: | Php Developer | Date: | Wed, 26 May 2010 20:09:24 +0000 |
| Subject: | Re: QuickForm2 validation | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-30575@lists.php.net to get a copy of this message | ||
Hi,
Thank your for your answer. It is my first use of pear in general and the code that I adapted to
QuickForm2 is a lot clearer and more compact now.
I'm wondering if there is a way to change dynamically the action of the post method. I had
already an answer explaing how to do it in the constructor. But it would be a lot better if it is
possible to do it for an already instantiated quickform2 object too. May be in the addDataSource
function but in that case what would be the syntax?
Thank you very much
----- Original Message ----
From: Alexey Borzov <borz_off@cs.msu.su>
To: Php Developer <pdeveloper@rocketmail.com>
Cc: pear-general@lists.php.net
Sent: Tue, May 25, 2010 4:40:42 AM
Subject: Re: [PEAR] QuickForm2 validation
Hi Anonymous,
On 25.05.2010 12:15, Php Developer wrote:
> Even if I added a rule, the user can still submit a form with an empty field. What would be the
> correct version of the following code:
>
> require_once "HTML/QuickForm2.php";
> $form = new HTML_QuickForm2('test');
> $fieldSet = $form->addFieldset()->setLabel('test');
> $title = $fieldSet->addText('title')->setLabel('Title:');
> $title->setValue("mytitle");
Here you override whatever value was submitted with your 'mytitle' value...
> $title->addRule('required', "Please provide title");
...and when this rule runs it checks 'mytitle' and finds it valid.
The correct way to set default values is
$form->addDataSource(new HTML_QuickForm2_DataSource_Array(array(
'title' => 'mytitle',
'Letter' => 'my letter'
)));
-- PEAR General Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php