Reputation: 226
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'
Upvotes: 0
Views: 118
Reputation: 1
Avoid changing of the system folder contents. Otherwise your changes will be lost after the next upgrade. The more correct approach is to override the validation rules.
In file application/classes/Model/user.php
:
<?php
class Model_User extends Model_Auth_User
{
public function rules()
{
$rules = parent::rules();
unset($rules['username']);
return $rules;
}
}
?>
Upvotes: 0
Reputation: 226
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
Upvotes: 1