2011-10-16 95 views
1

我在窗體中有一個正常的rails collection_select和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" 

這兩個都不禁用下拉菜單。有什麼建議麼?

+0

我張貼的答案,但它有很大的幫助,如果你能張貼上面的嘗試HTML輸出。 – bricker

+0

令人驚訝的是,所有的HTML o/p都是相同的 Pykih

+1

我認爲這個禁用的選項是禁用選項,而不是整個下拉本身。但我可能是錯的。 – Pykih

回答

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

不幸的是都沒有工作。 :-( – Pykih

+0

剛剛看過文檔,你必須傳遞一個空的選項散列,看看我的更新。 – bricker

0

什麼:

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