Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.4.0

Request #4534 QuickForm + "soft" rules.
Submitted: 2005-06-06 07:43 UTC
From: ej dot grace at imperial dot ac dot uk Assigned: avb
Status: Closed Package: HTML_QuickForm2
PHP Version: 4.3.10 OS: Linux
Roadmaps: 0.2.0    
Subscription  


 [2005-06-06 07:43 UTC] ej dot grace at imperial dot ac dot uk
Description: ------------ This is an edited version of a discussion on pear-general: I have come across the need to generate "soft" rules. I define a soft rule as one that can be overriden by the user, as oposed to the current "hard" rules which cannot be overridden. What I mean by this is a typical scenario where you may have a rule that checks that a person has entered their name according to some case formatting so for example. Surname Rather than sURnaMe There are however situations where the case formatting of a surname could not fit into the typical box of "capital first letter, the rest lowercase" hence not being able to use a filter rule. For example the surnames van Blogger al Tranger McTaggert Clearly break this "convention". Of course one could add exceptions for "van", "al" "Mc" prefixes but you still can't guarentee catching them all with a "strong" validation rule. What would be useful is to have a soft validation rule whereby, if it fails the usual message appears along with a checkbox saying "Yes I really want to submit this" that would override the associated rule. This can be done with some hacking about using groups, rules etc but it would be nice to have a addSoftRule() method, or some such that would generate the appropriate elements if the validation failed, and deal with overriding the rule if the checkbox is set. Of course such soft rules could be combined with hard rules (for example the 'required' rule). Have people looked at this before? I imagine it is a common want. Reproduce code: --------------- Implementation: There is no need to change the form of the rule callbacks, so for example to allow overriding of the 'required' rule one would do: $form->addRuleSoft('name','required','Please make sure this field is filled in','Check this box to override this rule'); If the validation method fails, the usual message 'Please make sure this field is filled in' will pop up along with a checkbox with the label 'Check this box to override this rule'. When the form is validated the associated auto-generated checkbox is tested if the rule fails, if the checkbox exists the rule is then passed. Actual result: -------------- In my opinion this type of concept will be very useful since it will allow tight rules to be met for a large percentage of the user input, while still allowing the user to add data that they know to be in the correct form.

Comments

 [2005-06-08 17:38 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2005-06-08 17:45 UTC] ej dot grace at imperial dot ac dot uk
That's interesting. I assume that the custom rule needs the element to be in a group. Presumably somewhere in the custom rule there would be something to add checkbox element to the group, and something else to say if the check box is checked to return true. Is that right? Would you mind sketching an outline of how this should be done, it would save a lot of time hacking around. Perhaps I can then extend the HTML_QuickForm adding a method which wraps this process automatically? Thanks, -ed
 [2005-06-08 17:49 UTC] ej dot grace at imperial dot ac dot uk
[Apologies if my last alteration my autoform filler re-wrote the Summary line incorrectly for me in the previous reply.]
 [2005-06-08 18:22 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2006-06-08 13:20 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2007-07-17 19:13 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!