How to Show Error Messages Next to Field

后端 未结 4 607
花落未央
花落未央 2020-12-13 19:16

I have a form with input fields/labels etc. How do I get the error message to show up next to the field? instead of clumped together at the top?

I am using devise, r

4条回答
  •  鱼传尺愫
    2020-12-13 19:39

    Just create a file in your initializers folder.

    config/initializers/inline_errors.rb

    Place this code in it:

    ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
      unless html_tag =~ /^
    }.html_safe else %{#{html_tag}}.html_safe end end

    PD: Sorry for my english.

提交回复
热议问题