Answer the question
In order to leave comments, you need to log in
How to set a name in Russian for each field in laravel during validation?
Hey!
I'm validating the fields, and started adding my posts in the style:
The :attribute field is required!
Unfortunately, instead of :attribute, the name of the field is substituted, and as a result, the view will be something like this:
The name field is required!
How to add Russian field names instead of :attribute so that it says: "Field "Name" is empty". The Last Name field is empty. ?
Answer the question
In order to leave comments, you need to log in
One of the validator arguments is $attributes, an array with custom attribute names.
\Validator::make($data, $rules, $messages, [
'name' => 'имя',
]);
public function attributes()
{
return ['name' => 'имя'];
}
I didn’t personally google about Russian, but you can do it like this
$validator = \Validator::make([
'filters' => $filters,
], [
'filters.filters.date_from.value' => 'bail|required|date',
'filters.filters.date_to.value' => 'bail|required|date',
], [
'filters.filters.date_from.value.required' => 'Укажите дату начала',
'filters.filters.date_from.value.date' => 'Укажите корректную дату начала',
'filters.filters.date_to.value.required' => 'Укажите дату конца',
'filters.filters.date_to.value.date' => 'Укажите корректную дату конца',
]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question