Set up all your validation rules in the model (such as username not empty
and only letters, email valid, etc. etc.).

On the save() action you validate with the model as usual.

On the login action, instead of calling save() on the model you would call
validates(), and since you want only to validate a few things (such as user
not empty, password not empty) you would unset those validation rules you
don't need at that time:

unset($this->User->validate['email']);
unset($this->User->validate['someotherfield']);

// Check if it validates

if ($this->User->set($this->data) && $this->User->validates())
{
        // Perform your thing to check user / password
}

-MI

---------------------------------------------------------------------------

Remember, smart coders answer ten questions for every question they ask. 
So be smart, be cool, and share your knowledge. 

BAKE ON!

blog: http://www.MarianoIglesias.com.ar


-----Mensaje original-----
De: [email protected] [mailto:[EMAIL PROTECTED] En nombre
de cecplex
Enviado el: Martes, 06 de Marzo de 2007 07:09 p.m.
Para: Cake PHP
Asunto: Different Validations on 1 Table (Model) Based on the Action

I have a login form that has a username and password required field.
THEN I have a Signup form that has a username and password and
firstname, lastname, email and other fields.

When I run the save(); function from my controllers, i want it to
validate differently based on the action. (Either a signup or a login)


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to