LoginSignup
0

More than 5 years have passed since last update.

date_selectの最初にオプションを追加する

Posted at

date_selectで実装してるセレクトボックスに
【Year】,【Month】のoptionを追加してくださいって言われたのでメモ

:promptを使えば指定したオプションを先頭にいれられる。

sample.html.erb
<%= date_select :hoge, :fuga, use_month_numbers: true, start_year: 2018, end_year: Time.zone.now.year, discard_day: true, prompt: {year: "year", month: "month"} %>

こんなかんじで出る
スクリーンショット 2019-03-22 12.37.24.png

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0