How to change the default rails error div “field_with_errors”

前端 未结 6 1050
名媛妹妹
名媛妹妹 2020-12-13 08:12

I\'m using sorcery for authentication along with twitter bootstrap.

I\'d like to style my error messages on my signup form in the style of twitter\'s bootstrap by ch

6条回答
  •  萌比男神i
    2020-12-13 08:45

    Using Rails 6 with Bootstrap 4 you'll need to add the is-invalid class. Without getting too fancy I just did:

    ActionView::Base.field_error_proc = proc do |html_tag, instance|
      html_tag.gsub("form-control", "form-control is-invalid").html_safe
    end
    

提交回复
热议问题