I am using the ruby gem simple_form for different forms around my site and was wondering if there was a way to combine/collapse the date input that is rendered by default:
= f.input :dob, label: "Date of Birth", as: :date, start_year: Time.now.year - 90, end_year: Time.now.year - 8, order: [:day, :month, :year]
This code produces three input field: day, month and year. But what I actually want is to have a single field for all the three, so the input could look like "05/05/1980". How can that be achieved?
In order to use html5 date fields you can do the following:
= f.input :dob, as: :string, input_html: {type: :date}
You passed :as param with wrong. using string type will make one field instead of 3 fields.
= f.input :dob, label: "Date of Birth", as: :string, start_year: Time.now.year - 90, end_year: Time.now.year - 8, order: [:day, :month, :year]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With