Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActiveModel: different validation messages per view

I use the same model in two views (containing forms) and I want to provide different validation messages per view. Example:

View 1:

Please fill in this bla bla

View 2:

Fill in foo foo

I followed the i18n guides to override the default error messages for the model but I can't find a way to differentiate them per view.

Is this possible?

like image 939
Lazarus Lazaridis Avatar asked May 14 '26 06:05

Lazarus Lazaridis


1 Answers

IMHO, you should be using two different view models. Hence, you will have two classes/models with Single Responsibility.

Panayotis

like image 85
p.matsinopoulos Avatar answered May 15 '26 21:05

p.matsinopoulos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!