I have a login form and a registration form . And both are attached to same table users. How do i validate both forms seperately in Model class. I have tried with two different functions, the code is below
class User extends AppModel
{
public function login()
{
public $private = array('username'=>array('required'=>array('rule'=>'notEmpty','message'=>'Username is reqired . So please fill the username')),'password'=>array('required'=>array('rule'=>'notEmpty','message'=>'Please enter your password.')));
}
public function register()
{
public $private = array('firstname'=>array('required'=>array('rule'=>'notEmpty','message'=>'Enter your first name'),'lastname'=>array('required'=>array('rule'=>'notEmpty','message'=>'Enter your lastname name'),'username'=>array('required'=>array('rule'=>'notEmpty','message'=>'Username is reqired . So please fill the username')),'password'=>array('required'=>array('rule'=>'notEmpty','message'=>'Please enter your password.')),'role'=>array('valid'=>array('rule' => array('inList', array('admin', 'author')),'message' => 'Please enter a valid role','allowEmpty' => false))));
}
}
My doubt is how wil the controller know which function is for login or register. How do i need to write the code in controller to call this ????