Quickform Validation not occuring
| From: | Adam Hubscher | Date: | Sun, 05 Dec 2004 20:15:23 +0000 |
| Subject: | Quickform Validation not occuring | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-16019@lists.php.net to get a copy of this message | ||
First I suppose I should say how I have my complete script set up. I have a
few classes, each doing their own set of routines... one for building the
forms, one for displaying the site using smarty templates, my database
handling class, and then a controller class to direct everything to where it
needs to go.
My problem is this, I have gotten everything to work to the point of where I
am able to either validate() the form, or create the form.
Of course before submition, the form is created, and output to the browser.
On submition, the form is "validated" and then the data is submitted into
the database. However, it is not TRUELY being validated. The validate
function returns true EVERY time.
After testing, which included placing the addRule statement everywhere I
could think of it being read before the form is displayed... adding a little
piece of code that returned true whenever the addRule function completed
successfully... and even testing if the rule is actually added in the first
place, I discovered that although the addRule function is being called and
completing successfully, there is no actual rule being added. (this is
assuming that the isElementRequired method does in fact check to see if,
say, the 'LoginID' textbox is a required form element based upon the form's
rules). So in this, I discovered that the form validation... was being
validated because there were no rules for it to validate.
Now, since I have multiple classes and such, and at the moment... since its
a work in progress, its not exactly the cleanest looking code, I'm going to
leave it out of this message for the moment. Here is a general model of how
the flow is controlled:
index.php -> displayed with menu -> menu item clicked -> $_GET variable
sends control to the 'Controller' class (Add New User) -> Controller directs
flow to the 'Form' class -> form is created, passed to the smarty handling
class -> form is output -> submition -> validation -> database.
Thanks for any help I can receieve!
- Adam