In that case, instead of unsetting each field you don't want validated, just set validation to a new, abridged array of rules. Something like:
$this->User->validate = array( 'username' => VALID_NOT_EMPTY, 'password' => VALID_NOT_EMPTY ); rhett waldock clearsite new media -----Original Message----- From: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of cecplex Sent: Tuesday, March 06, 2007 5:15 PM To: Cake PHP Subject: Re: Different Validations on 1 Table (Model) Based on the Action What if I have 15 fields and I only want 2 of them validated. Is there no construct available to let me validate a specific set of fields? On Mar 6, 6:01 pm, "Mariano Iglesias" <[EMAIL PROTECTED]> wrote: > 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: cake-php@googlegroups.com [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 cake-php@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---