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

Bug #1431 Feature Request: Tying rules/filters to submit buttons
Submitted: 2004-05-18 15:01 UTC
From: vasilyev at math dot uchicago dot edu Assigned:
Status: Wont fix Package: HTML_QuickForm
PHP Version: Irrelevant OS: irrelevant
Roadmaps: (Not assigned)    

 [2004-05-18 15:01 UTC] vasilyev at math dot uchicago dot edu
Description: ------------ It would be desirable to be able to bound rules and filters to submit buttons. For example, if the form has two submit buttons "Update" and "Remove", I would like to perform full validation if "Update" button was pressed, and perform no (or little) validation if "Remove" button was pressed. Also, it would be nice to have a method QuickForm::isSubmitted() to see if the form was submitted (this is useful if there are several forms on one page with trackSubmit flag).


 [2004-05-19 11:16 UTC] avb
As for the first suggestion, please look at HTML_QuickForm_Controller package: it allows binding actions to specific buttons. QuickForm::isSubmited() method does not strike as too useful. If $trackSubmit is on this can be achieved by e.g. if (0 == count($form->getSubmitValues())) { // not submitted } else { // submitted }
 [2004-05-19 16:00 UTC] vasilyev at math dot uchicago dot edu
HTML_QuickForm_Controller allows binding actions to specific buttons. What I proposed was binding rules and filters to submit buttons. This is not as important for server side validation (because you can always check what button was pressed and perform needed validation) as it is for client side validation. Even multipage form created using HTML_QuickForm_Controller won't work as expected if you try to perform client side validation - then when you press Back button the form will be validated using JavaScript (while there should not be any validation done on Back button). It would be nice to be able to at least exclude some submit buttons from client side validation. This will fix the above mentioned problem with HTML_QuickForm_Controller. I agree with your remark on isSubmitted() method. However I still think that having such a method is a good idea - it will make the code more readable.
 [2004-05-19 20:20 UTC] avb
OK, now I understand your point. Tying rules to specific buttons will add too much unneeded (IMHO) complexity. Fixing the behaviour of Back buttons in wizards and such can be done by some JS magick. Back button's onclick handler will just have to remove form's onsubmit handler and no validation will take place.