在哪些方面做改变所以检查了?我不想检查兼容性重复字段的密码字段。
我在 Kohana 用户控制器中的添加功能
public function action_add() {
$title = 'Add User';
$this->template->title = $title;
$this->template->content = View::factory('action/users/add')
->bind('title', $title)
->bind('message', $message)
->bind('errors', $errors);
if (HTTP_Request::POST == $this->request->method()) {
try {
// Create the user using form values
$user = ORM::factory('user')->create_user($this->request->post(), array(
'username',
'password',
'email',
'last_name',
'first_name',
'middle_name'
));
// Grant user login role
$user->add('roles', ORM::factory('role', array('name' => 'login')));
// Reset values so form is not sticky
$_POST = array();
Session::instance()->set('message', "You have added user '{$user->username}' to the database");
Request::current()->redirect('/admin/' . $this->request->param('lang') . '/action/users' );
} catch (ORM_Validation_Exception $e) {
// Set failure message
$message = 'There were errors, please see form below.';
// Set errors using custom messages
$errors = $e->errors('models');
}
}
}