2016-07-29 172 views
1

我在kohana驗證中有一個回調。我發送錯誤信息是這樣的:kohana自定義驗證錯誤消息

public function way(Validate $array, $field) 
    { 
     if (something) 
     { 
      $array->error($field, 'super error message', array($array[$field])); 
     } 
    } 

它的工作原理,但是當我打印出來的消息

echo $errors['field']) 

返回formName.field super error message

如何擺脫formName.field的?

回答

1

這些是在Kohana Core或模塊或應用程序中配置的消息。 您可以在消息文件夾 (如默認驗證信息在系統 - >信息 - >驗證.php 你在你的應用程序中複製這個文件,並從它們中刪除:字段,它將擺脫字段名稱。

'not_empty'  => ':field must not be empty', 

將其更改爲

'not_empty'  => 'must not be empty',