Consider the following <input> array in my form:
<input type="text" name="title[1]" value="">
<input type="text" name="title[2]" value="">
<input type="text" name="title[3]" value="">
The numbers (1,2,3) refer to different languages. 1 = English, 2 = German, etc.
How can I add custom error messages for an input array?
I have tried the following without success in my app/lang/en/validation.php:
<?php
return [
'custom' => [
'title.1' => [
'required' => 'The english title is required.',
],
'title.2' => [
'required' => 'The german title is required.',
],
'title.3' => [
'required' => 'The italian title is required.',
],
],
];
?>
Laravel throws the default error messages instead of using my custom messages:
The title.1 field is required.
The title.2 field is required.
The title.3 field is required.
Thank you for any help you can provide!
EDIT: It works if I pass the message to my validator like this:
$messages = array(
'title.1.required' => 'The english title is required',
);
$validator = Validator::make($data = Input::all(), $rules, $messages);
But I can't get it to work in the app/lang/en/validation.php file.