Re: HTML_QuickForm & Rules.
| From: | Helgi | Date: | Tue, 16 Dec 2003 14:41:58 +0000 |
| Subject: | Re: HTML_QuickForm & Rules. | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-9576@lists.php.net to get a copy of this message | ||
Ahh i see :)
Now i understand ... :D Thanks guys ;)
Btw. when some of you talked about lossing flexability and all that ...
I can see that now when i started think about it ;P I maybe posted some of this and didn't think that much :)
And again Thanks to all of you! :D
Bertrand Mansion wrote:
<helgi@trance.is> wrote :Hmmm ... Well okey lets say I want the user to write his email address in the form ... There for i use $form->addRule('email', 'Please insert your email', 'email'); so the user doesn't input invalid email ... But I also want this to be a required field ... I was wondering if i can somehow user email and required on same rule ? Or do i have to make 2 diffrent rules ? like: $form->addRule('email', 'Doesn't look like a email', 'email'); $form->addRule('email', 'There must be a email', 'required');That's the way to go. But remember the order you set your rules is important. You first want to check if the field is not empty, then if it's a valid email address. So... $form->addRule('email', 'There must be a email', 'required'); $form->addRule('email', 'Doesn't look like a email', 'email');Also i was wondering the same with compare ... I saw in the manual like I said a way with compare'ing password fields and have them also be a required fields but there you had to make a function that made the compare and then you used it like this: $form->addRule('passwd1', 'Please enter password', 'required'); $form->addRule('passwd2', 'Please confirm password', 'required'); $form->addFormRule('cmpPass');There is a new 'compare' rule in 3.2 $form->addRule(array('cmpPasswd', 'cmpRepeat'), 'The passwords do not match', 'compare'); Look at the new examples in the docs directory. http://cvs.php.net/co.php/pear/HTML_QuickForm/docs/rules-builtin.php?login=2 &r=1.2 Now, addRule() also accepts an array of elements.And then I come again to the thing i was wondering isn't there any inbuilt feature in the QuickForm to make the same thing compare and be required, and same with email ... If not then it would be a nice feature ...Not a nice feature at all as it removes flexibility, reusability, updates, etc. But you are free to create such a custom rule on your own using callbacks. Bertrand Mansion Mamasam