working with a Laravel 5 project, I'm trying to use my custom Request class for validation, and I have a form with several inputs which name's are arrays. Example input :
<input name="en[title]" type="text">
However, in the Request class, I must declare the rule for the input above as:
public function rules()
{
return [
'en.title' => 'required|min:3',
];
}
This works fine, and I can cycle through the $errors
variable in my view, without a problem. However, if I want to use some extended library to match the input names to the errors in the MessageBag
, and display them nicely inline (below each form input), since the MessageBag
keys do not match... I can't.
Is there a way to post process the error bag? Or maybe alias the error bag keys?
The only solution I can come up with, is to cycle through the $errors
in my view, check for the desired key-key translation, and do that manually. But I find this very anti-laravelesque.
Any ideas?
Thanks!
You can handle this in the request object. After validation put the your key with the validation message in the messages array.