Form Validation Custom Messages (different fields with same name)

Hey, I'm trying to create custom messages for errors found in form input validation.

The issue I'm having is I can't seem to find a way to create separate messages for inputs with the same name, but in different pages of the application

Suppose I have two pages with two different forms both with an input named "description". Is there a way to specify two different custom messages in validation.php for these inputs, so I can use the proper message for each form?

Thanks in advance.

  • 2 weeks ago

How about using 2 different FormRequests and specifying the messages() function?

Or if you're using a single FormRequest you could maybe dynamically set the messages return array by checking a form id hidden input field