禁用下拉列表

时间:2011-10-16 08:53:38

标签: ruby-on-rails-3.1

我有一个普通的rails collection_select并在我的表单中选择下拉列表。我想在此下拉菜单中禁用任何其他选项。

= f.collection_select :genre, DecodeConstant::PROJECT_TYP_DD, :id, :display_value, :html_options => { :disabled => @project.status == "RS_A" }

= f.select :currency_code, options_for_select([['Indian Rupee', 'INR'], ['United States Dollar', 'USD']]), :disabled => @project.status == "RS_A"

这两项都没有禁用下拉列表。有什么建议?

3 个答案:

答案 0 :(得分:4)

f.collection_select :genre, DecodeConstant::PROJECT_TYP_DD, :id, :display_value, {}, { :disabled => @project.status == "RS_A" }

答案 1 :(得分:0)

怎么样:

f.collection_select :genre, DecodeConstant::PROJECT_TYP_DD, :id, :display_value, {}, { :disabled => true }

答案 2 :(得分:0)

f.collection_select :genre, DecodeConstant::PROJECT_TYP_DD, :id, :display_value, { disabled: lambda{|values| values }}, prompt: true