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
フォルダーで機能しているように見えるため、ファイルに名前を付けました。これは、その下で呼び出されます( GitHubSYSPATH/messages/validate.php
で参照してください)。
エラーメッセージはベースファイルから継承できますか、それともフォームごとにすべてのエラーメッセージをコピーする必要がありますか?