Search code examples
kohana-3kohana-auth

how to sign up with different fields in kohana


The Model_Auth_User class in Kohana uses 'username', 'email','password' to create a new user what if i want it to take only 'email', 'password' and also modify the validation to validate 'email_confirm' instead of 'password_confirm'


Solution

  • Finally i did it, All what I have to doe is to comment some lines which add the rules of validating user input open C:\xampp\htdocs\kohana\modules\orm\classes\Model\Auth\User.php and comment lines from 33:38 inclusive as following:

        public function rules()
    {
        return array(
            //as we don't have a username we don't need to validate it!
            // 'username' => array(
            //  array('not_empty'),
            //  array('max_length', array(':value', 32)),
            //  array(array($this, 'unique'), array('username', ':value')),
            // ),
            'password' => array(
                array('not_empty'),
            ),
            'email' => array(
                array('not_empty'),
                array('email'),
                array(array($this, 'unique'), array('email', ':value')),
            ),
        );
    }
    

    You only keep the rules for validating what you need