FormRequest 'nice names' for arrays

Posted 1 month ago by chilly2go

I did some searching but did not find a solution for my Problem using FormRequests. (Just using the Validator I found this StackOverflow question)

When submitting a form as array (imagine a table with a new instance of an object in each row) Laravel allows me to easily validate this. Now if I want to provide better error messages to the user the message "arrayname.index.fieldname is required" does not help much. If I provide the "attributes()" method I can translate the field name shown to the user from "arrayname.index.fieldname" to "my field name" (just provide same key as for validation rule and assign a name).

But this way I lose the information which row provided the data that lets the validator fail our request.

I found some options to meddle with the request data before validation but I could not figure out a proper way to handle this.

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.