coldfusioncfwheels

Where should we write validation code for a form in cfwheels?


I have just started learning cfwheels. I was working on the sample "Social Networking Site" example present in the site(http://cfwheels.org/screencasts/series/1). I have a doubt. We have register.cfm and login.cfm two views present. Both the veiws are using the user object created from Person.cfc(modal).

All the validations that are required in the registration form , we have written inside Person.cfc init() method. Now on the login.cfm we have two fields named Email and password and I want to validate the email to be in correct format in server side before checking for valid Email/Password combination.

Now where should I write this validation code for login.cfm?


Solution

  • The server side validation should be done on the action inside the Controller. For example if you are submitting the form to doLogin action of the Authentication controller/component, the validation code should go inside the doLogin() function of the same controller.