小编Tri*_*ote的帖子

在Rail 3中的自定义label_tag帮助器中跳过HTML转义

我有这个很好的类ErrorFormBuilder,它允许我在窗体视图中的相应字段附近添加错误描述:

    class ErrorFormBuilder < ActionView::Helpers::FormBuilder
  #Adds error message directly inline to a form label
  #Accepts all the options normall passed to form.label as well as:
  #  :hide_errors - true if you don't want errors displayed on this label
  #  :additional_text - Will add additional text after the error message or after the label if no errors
  def label(method, text = nil, options = {})
    #Check to see if text for this label has been supplied and humanize the field name …
Run Code Online (Sandbox Code Playgroud)

ruby validation ruby-on-rails-3

3
推荐指数
2
解决办法
3542
查看次数

标签 统计

ruby ×1

ruby-on-rails-3 ×1

validation ×1