0

我正在尝试select使用自定义表单助手覆盖 Rails 的方法,以便所有选择框disabled默认获取一个属性:

class LabelFormBuilder < ActionView::Helpers::FormBuilder

  def select(method, choices, options = {}, html_options = {})
    html_options.reverse_merge! :disabled => true
    super(method, choices, options = {}, html_options = {})
  end

end

问题是代码不起作用,并且它不会改变选择框的呈现方式。它也不会抛出错误。

这将是我用来调用该函数的视图代码:

<%= f.select(:person_id, current_user.person_names, {:prompt => 'Please select...'}) %>

我在这里想念什么?

谢谢你的帮助...

4

1 回答 1

0

试试吧

<%= f.select(:person_id, current_user.person_names, {}, {:prompt => 'Please select...'}) %>
于 2012-11-10T19:17:55.650 回答