0
votes

Not sure how to best solve this issue.

Right now, on my forms, when an input has an error, the error message is properly displayed next to the input field. This is perfect.

One of my forms, the model has a custom validation that can cause an error unrelated to any of the inputs on the form.

The best solution would be to display an error div above the form with the general errors, but I do not want to duplicate the errors that would be displayed inline (next to the input fields).

How could I display errors at the top of the form without showing errors that would be duplicated below?

Thanks for any assistance!

1
@zeantsoi Basically my thinking is that I exclude any error messages on attributes that have a form input, but I am unsure how to get a list of inputs a form has and how to make it generic.Greg Olsen
@zeantsoi I am also hoping this problem has been solved before, but I have not been able to find a solution yet.Greg Olsen

1 Answers

1
votes

Errors that are associated with a field are errors[:field_name].

So perhaps you should try displaying this at the top:

errors[:base]

The reason is that errors[:base] shows errors that are associated with the object as a whole and not a specific field.