如何滾動自己的簡單的幫手,就像
def datetime_text_fields(object_name, method)
html = text_field_tag("#{object_name}[#{method}(3i)]", Date.today.day.to_s, :length => 2)
html << select_month(Date.today, :field_name => "#{object_name}[#{method}(2i)]")
html << text_field_tag("#{object_name}[#{method}(1i)]", Date.today.year.to_s, :length => 4)
html << " "
html << text_field_tag("#{object_name}[#{method}(4i)]", Time.now.hour.to_s, :length => 2)
html << ":"
html << text_field_tag("#{object_name}[#{method}(5i)]", Time.now.min.to_s, :length => 2)
end
隨意添加更多格式的東西/分離器等,但它基本上返回到正確的領域導軌名稱被標識爲DateTime。 Rails的預計,命名爲喜歡date(1i)
領域,1I =年,2I =月等
老實說,我沒有測試或任何東西,但在控制檯輸出看起來相當有說服力;)
來源
2010-07-20 11:15:56
lwe