Is there a way to tell Rails to not create div.field_with_errors
around both label and actually field, but to create div.error
around them both?
E.g. snippet from my view with the form (written in HAML)
= form_for @user do |f|
%div.clearfix
= f.label :name
%div.input
= f.text_field :name
I want in the case of error the root div to be div.clearfix.error
and avoid that field_with_errors
. Can I do so?
As another option, can I make formtastic to create Bootstrap-styled elements, w/o formtastic's css and html classes, but with bootstrap's ones. Can I make something with error fields in the case of using formtastic?
@flowdelic's answer seems to be the simplest fix. However, the names are incorrect. This may be due to the Rails/Bootstrap version, but this works for me.
/* Rails scaffold style compatibility */
#error_explanation {
@extend .alert;
@extend .alert-error;
@extend .alert-block; /* optional */
}
.field_with_errors {
@extend .control-group.error
}