我創建了一個文件一堆錯誤APPPATH/messages/validate.php
下了一堆共同消息,如...Can Kohana 3的驗證錯誤是否會繼承?
return array(
'not_empty' => ':field must not be empty.',
'matches' => ':field must be the same as :param1',
'regex' => ':field does not match the required format',
'exact_length' => ':field must be exactly :param1 characters long',
'min_length' => ':field must be at least :param1 characters long',
'max_length' => ':field must be less than :param1 characters long',
'in_array' => ':field must be one of the available options',
'digit' => ':field must be a digit',
'email' => 'You must enter a valid email.',
'name' => 'You must enter your name.',
'enquiry' => 'You must enter your enquiry.',
'captcha' => array (
'Captcha::valid' => 'The characters you entered did not match the image. Please try again.',
'not_empty' => 'You must enter the characters from the image.'
)
);
,當我得到這樣的錯誤$errors = $post->errors('validate')
這個偉大的工程。
有沒有使用這些錯誤基地錯誤的方式,如果我有一個單獨的形式,需要更多的,我可以使用,只有在它的差異一個單獨的文件,例如,它可能看起來像
return array(
'permissions' => 'Please agree to the permissions',
);
所以,很顯然,任何email
錯誤信息將來自validate.php
(繼承),但任何permissions
錯誤將來自與permissions
錯誤定義新的文件。
我命名的文件validate.php
因爲繼承行爲似乎與system
文件夾的工作,這就是它被SYSPATH/messages/validate.php
下稱爲(見它GitHub)。
我的錯誤消息是否可以從基本文件繼承,還是應該複製每個表單的所有錯誤消息?
Hey Shadowhand,謝謝 答案。你的意思是在系統文件夾中更改'validate'嗎?因爲當我將這個'validate'文件複製到'APPPATH/messages'文件夾中時,它不起作用。 – alex 2010-07-22 00:27:51
它應該放在'APPPATH/messages'中。 – shadowhand 2010-07-23 21:48:29