2012-02-01 61 views
0

在try catch块内的我的Model_Auth_User上调用update_user(),但在$ e-> errors('validation')调用中得到一个具有以下结构的多维数组:Handle用户更新Kohana中的验证

Array 
(
    [_external] => Array 
     (
      [password] => Array 
       (
        [0] => min_length 
        [1] => Array 
         (
          [0] => asdf 
          [1] => 8 
         ) 

       ) 

     ) 

) 

在那里我通常得到一个数组开始没有_external包装。任何人都知道发生了什么事?

回答

0

我认为Kohana无法在您指定的'验证'文件中找到消息,因此它将消息作为“文件/字段/规则”返回。

看一看这里: http://kohanaframework.org/3.2/guide/api/Validation#errors

特别是,这些条件句:

if ($message = Kohana::message($file, "{$field}.{$error}")) 
{ 
    // Found a message for this field and error 
} 
elseif ($message = Kohana::message($file, "{$field}.default")) 
{ 
    // Found a default message for this field 
} 
elseif ($message = Kohana::message($file, $error)) 
{ 
    // Found a default message for this error 
} 
elseif ($message = Kohana::message('validation', $error)) 
{ 
    // Found a default message for this error 
} 
else 
{ 
    // No message exists, display the path expected 
    $message = "{$file}.{$field}.{$error}"; 
} 

另外,我觉得你需要存储的信息在以下文件位置:./application/messages/验证/ _external.php

+0

不是我正在寻找,但这有助于。我只是认为这是某种接收_external数组的错误。 – 2012-02-02 16:59:02