2014-02-08 42 views
2

我想佔位符文本(預定義的一個「選擇任何狀態」)爲我的下拉menu.The以下是我的下拉菜單如何添加佔位符下拉菜單

<%= f.select :status,[[],['Created','Created'],['Deleted','Deleted'], 
['Modified','Modified'],['Stored','Stored'],['Trained/Broken','Trained/Broken'], 
['Unnecessary','Unnecessary']] %> 

Ruby代碼:1.9。 3條 的Rails 3.2.13

在此先感謝

+0

查看問題http://stackoverflow.com/questions/6501199/ruby-on-rails-form-select – Danny

+0

<%= f.select:status,[['Select Status',nil],['Created', '創造'],[ '刪除', '刪除'],[ '修改', '修改'],[ '存儲', '存儲'],[ '經過培訓/斷', '經過培訓/斷'],[ '不必要','不必要']],:required => true%>當字段爲空時也不起作用 –

+0

應該完成這項工作! – Danny

回答

4

您可以使用prompt此:

<%= f.select :status,[[],['Created','Created'],['Deleted','Deleted'], 
['Modified','Modified'],['Stored','Stored'],['Trained/Broken','Trained/Broken'], 
['Unnecessary','Unnecessary']], prompt: "Please Select" %> 
+0

Thankz !! Rich Peck,工作正常。我想要這個字段爲 :required:true one.If user does not fill this field should it prompt message such as「You should fill it」 –