SooDesuNe
SooDesuNe

Reputation: 10030

Ruby on rails form input error formatting

The default behavior for a regular rails form that has errors is to 1) list the errors in a div, with the text coming from errors_for and 2) to place a div around the offending inputs with a red border. This question is concerning #2.

I'd like to know how rails goes about applying that div with the red border.

I'd like to know because I have some form inputs that aren't generated with f.text_field (for example), but they are attached to a model that can have errors.

I looked around in the source of action_view/helpers/form_tag_helper.rb All I was able to figure out is that form errors aren't applied by form_tag_helper

Upvotes: 0

Views: 870

Answers (1)

gjb
gjb

Reputation: 6317

The red border is added by ActionView::Base.field_error_proc

To change this behaviour: http://guides.rubyonrails.org/active_record_validations_callbacks.html#customizing-the-error-messages-html

Upvotes: 1

Related Questions