2012-12-29 37 views
1

我可以正常放一個佔位符在表單中使用類似佔位符在select_date軌道3

:placeholder => "something" or {:placehoder => "something"} 

我是如何把一個佔位符月和一年內select_date有點難倒。我用這

<%= select_date(date = Date.current, :order => [:month, :year]) %> 

我想在月份和年份

任何人都知道如何做到這一點,請

感謝

回答

6

佔位符中選擇一個佔位符?沒有聽說過這樣的事情。也許你想要:

<%= select_date(date = Date.current, :order => [:month, :year], :prompt => { :month => 'Select month', :year => 'Select year' } %> 

Here is the answer這啓發了我,所以你可能要信貸philipth。我只是調整了你的情況。如果您需要更多信息,您可以檢查documentation。你可以發現有這樣的例子:

# Generates a date select with custom prompts. 
date_select("article", "written_on", :prompt => { :day => 'Select day', :month => 'Select month', :year => 'Select year' }) 
+0

非常感謝您的回答,我可以看到,如何工作..只是試了一下,現在的提示是下拉而不是默認值內?有任何想法嗎? – Richlewis

+0

我相信你可以從select_date刪除'date = Date.current',因爲很可能你將默認值 – mkk

+0

設置爲:default =>:prompt?所以選擇提示作爲默認...是可能的?嗯嗯不工作 – Richlewis