我正在尝试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...'}) %>
我在这里想念什么?
谢谢你的帮助...