开发者

kohana 3.1 orm validation on updating user details

开发者 https://www.devze.com 2023-03-16 10:20 出处:网络
I\'m running a update_user form through $user = ORM::factory(\'user\', $id)->update_user($this->request->post(), array(

I'm running a update_user form through

$user = ORM::factory('user', $id)->update_user($this->request->post(), array(
  'username',
  'password',
  'email'
));

And pre-populating the form fields username and email with the current user, and leaving the password blank in-order to be 'unchanged'

But on submission its picking up all the validation messages from create_user from the 'user' model

开发者_StackOverflow

So i'm getting:

"username already taken"
"email address already taken"
"password can't be blank"

Does anyone know how your suppose to get round this?


    $user = $this->get_user();

    if ( ! $user->loaded())
    {
        throw new Exception_Deny;
    }

    if ($_POST)
    {
        try
        {
            $user->update_user($_POST, array(
                'username',
                'email',
                'password',
            ));
        }
        catch (ORM_Validation_Exception $e)
        {
            $this->add_errors($e);
        }
    }

    $this->content = View::factory('user/update');

works absolutely properly - gives an error only when Im trying to assign existent another user's username or password... Check anything you've overrided in ORM or Model_User classes.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号