Php call_user_func_array()要求参数1是有效的回调,没有数组或字符串,因为Kohana 3.3.4
嘿,伙计们,我已经阅读并研究了kohana orm和auth模块。所以我想实现我的网站am管理部分。我发现了上面的错误,我在谷歌上搜索过,但似乎找不到答案。am使用Kohana 3.3.4 因此,a创建了一个名为admin的控制器:Php call_user_func_array()要求参数1是有效的回调,没有数组或字符串,因为Kohana 3.3.4,php,authentication,orm,kohana,kohana-3.3,Php,Authentication,Orm,Kohana,Kohana 3.3,嘿,伙计们,我已经阅读并研究了kohana orm和auth模块。所以我想实现我的网站am管理部分。我发现了上面的错误,我在谷歌上搜索过,但似乎找不到答案。am使用Kohana 3.3.4 因此,a创建了一个名为admin的控制器: <?php defined('SYSPATH') or die('No direct script access!'); class Controller_Admin extends Controller_Dev { public $templat
<?php defined('SYSPATH') or die('No direct script access!');
class Controller_Admin extends Controller_Dev
{
public $template = 'login_template';
public function action_index()
{
if (Auth::instance()->logged_in()) {
$this->redirect->body('admin/dashboard', 302);
}
$this->redirect('admin/login');
}
//lets login user
public function action_login()
{
$view = new View('admin_login');
$this->template->title = "Log in";
if ($_POST) {
$user = ORM::factory('user');
$status = $user->login($_POST);
if ($status) {
$this->redirect('admin/dashboard', 302);
}
else {
$errors = $_POST->errors('admin/login');
}
}
// Display the login form
$this->template->content = $view;
}
//lets logout user
public function action_logout()
{
Auth::instance()->logout();
$this->redirect('admin/login', 302);
}
//lets register new users
public function action_register()
{
$view = View::factory('admin_register')
->set('values', $_POST)
->bind('errors', $errors);
$this->template->title = "Registration Page";
if ($_POST)
{
$user = ORM::factory('User');
// The ORM::values() method is a shortcut to assign many values at once
/* $external_values = array(
// The unhashed password is needed for comparing to the password_confirm field
'password' => Arr::get($_POST, 'password'),
// Add all external values
) + Arr::get($_POST, '_external', array());
$extra = Validation::factory($external_values)
->rule('confirm_password', 'matches', array(':validation', ':field', 'password')); */
try
{
//$test = $extra; //Arr::get($_POST, 'password');
//$view->test = $test;
$data = $this->request->post();
$user->register($data);
// Redirect the user to his page
$this->redirect('admin/login');
}
catch (ORM_Validation_Exception $e)
{
$errors = $e->errors('models');
}
}
$this->template->content = $view;
}
我最近也犯了同样的错误。您需要更改行:
array(array($this, 'username_available')),
要行(用户名):
如中所述
我希望这对您有所帮助。模型的验证规则::$规则和额外验证它们有不同的语法。你把它混合在模型里<代码>密码和电子邮件规则错误。ok@bato3。谢谢你的评论。你能告诉我一个更好的方法来实现身份验证系统吗?我不知道,我的方法更好,但我使用的是本机模块:+ORM驱动程序:谢谢,伙计。这很有帮助
array(array($this, 'username_available')),
array(array($this, 'unique'), array('username', ':value')),