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

Bug #185 Problems with validate() with multiple forms or preexisting _get/_post vars
Submitted: 2003-11-02 11:22 UTC
From: fferreres at ojf dot com Assigned: avb
Status: Closed Package: HTML_QuickForm
PHP Version: 4.3.3 OS: All
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 49 - 41 = ?

 
 [2003-11-02 11:22 UTC] fferreres at ojf dot com
Description: ------------ This is probably not a bug, but a real nuissance, so my apologies if this does not belong here... Creating two or more forms with QuickForm works perfectly. However, if one uses ->validate() as a test for process()ing, then when any one form is submited, all forms are validate()ed and processed. Haven't found any other way to determine if a form is submited expect creating hidden fields and cheching them along with validate() for each form. Also, if two forms share elements with identical names, worng data would be fed to the other forms. Reproduce code: --------------- Create two or more forms forms and display them on one page. Submit any of the forms. All forms are validated (and processed or errors shown for all forms depending on rules). Expected result: ---------------- Only the actual submited form is treated as actually having been submited. Actual result: -------------- All forms are validate()d and thus resulting in errors on non submited forms are displayed. (lots of hidden variables are needed on each page to get around this behaveour of validate()). Side Comments: 1) It could probe usefull if QuickForms grouped each form's variables into an array like $POST_[formname][elementx]([...]). One should always use the interface to Quickforms and never mess the global _POST (_GET) arrays, so this change should not break any prior apps. 2) Page_Controller would be more usefull if pages wouldn't need to extend the Controller page class, as it makes it very hard to building dinamic multipage forms. 3) Another problem I see is that if you use a post or variable to determine which form to load (or to select a specific row for editing) then Quickforms treats it as form submited, resulting in errors shown to the user. Thus, one is forced to either map & unset the _post/_get array before calling validate after checking a hidden var (or session var), or doing without validate all together.

Comments

 [2003-11-02 16:45 UTC] avb
This will be addressed in upcoming 3.2 release. You'll be able to pass a parameter to constructor that will make QuickForm add a special hidden element to the form and check its existence in submitted values. The form will be treated as submitted only if this element is present. Besides, if you want to submit a bug for QF_Controller, please do so in its own category not within a bigger report for QF.
 [2003-12-18 08:49 UTC] tobias dot nix at web dot de
Hello, looks like this is fixed. How can I enable the feature from HTML_Quickform Bug #185? http://pear.php.net/bugs/bug.php?id=185 http://pear.php.net/package-changelog.php?package=HTML_QuickForm - Added possibility to check whether form was actually submitted (see also bug #185). Thanks, Tobias.