我有一个登录表单和一个注册表单。两者都附加到同一个表用户。我如何在模型类中分别验证这两种形式。我尝试了两种不同的功能,代码如下
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))));
}
}
我的疑问是控制器如何知道哪个功能用于登录或注册。我如何需要在控制器中编写代码来调用它????