Form Validation Custom Messages (different fields with same name)

aND04 posted 1 year ago

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.

jmp909 replied 1 year 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

Sign in to participate in this thread!

We'd like to thank these amazing companies for supporting us