我在一个文件中创建了一堆错误,APPPATH/messages/validate.php
其中包含一堆常见消息,例如......
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 上的内容)。
我的错误消息可以继承自基本文件,还是应该只复制每个表单的所有错误消息?