I use form model binding with a eloquent relation like customer -> hasOne -> adres. Everything on the form and database updates is working well.
In my request validation I can do something like:
public function rules() {
return [
'adres.firstname' => 'required|min:5',
];
}
This is working well, but I don't like the error message: "The adres.firstname field is required."
I should be able to change the error message in validation.php:
'custom' => [
'adres.firstname' => [
'required' => 'Please enter your first name',
],
],
But it is not accepting "adres.firstname"? Just a single fieldname will work. Can somebody explain to me how I can change the message?
I tried the attributes in validation.php as well but it has the same problem.
What actually is working is add a messages function:
public function messages() {
$messages = [];
$messages['adres.firstname.required'] = 'Please fill in your first name!';
return $messages;
}
But I build a multi language site, and I don't know how to translate this way.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community