« Return to Thread: [QuickForm] - Form rules?

Re: [QuickForm] - Form rules?

by Alexey Borzov :: Rate this Message:

| View in Thread

Hi Olaf,

On 24.04.2012 2:43, Olaf Gleba wrote:
>> So I ran into this tutorial:
>> http://ericlondon.com/using-pear-library-html-quickform2-create-simple-authentication-form-custom-validation-callback
>>
>> And I noticed that he does implement a form rule using a callback, I
>> was under the impression that form rules didn't exist anymore ....
>
> Do you have any references for your suggestion?
>
> AFAIK form rules are still a main part of what QuickForm2 makes sweet and valuable.

Form rules in QF were special callbacks set with addFormRule():
http://pear.php.net/manual/en/package.html.html-quickform.html-quickform.addformrule.php

They were given all form's values and could return errors for several form
elements at once.

In QF2 you can add a callback rule to the form, as is done in above tutorial,
and it will receive all form's values. However it will set an error for the form
itself, not for several elements in the form. A better approach is a custom rule
subclass as written in my older email quoted by Mark.

--
PEAR General Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

 « Return to Thread: [QuickForm] - Form rules?