I’m using simple_form gem on a form, and want to use date fields with three text_fields fields instead of three select fields.
I tried this:
<%= profile_form.simple_fields_for :birthday do |date| %>
<%= date.input :day, :as => :string, :label => "Dia", :input_html => { :maxlength => 2 } %>
<%= date.input :month, :as => :string, :label => "Mês", :input_html => { :maxlength => 2 } %>
<%= date.input :year, :as => :string, :label => "Ano", :input_html => { :maxlength => 4 } %>
<%- end -%>
But that creates three div’s, three labels and it’s a mess.
The ideal scenario was to have one label and three string fields in line.
Any ideas how I can create that custom input?
With the help of the mailing list of the simple_form I finally got it.
The custom input looks like this:
The day, month and year are virtual attributes that needed to be created.
I’ve added them to a module so that they can be mixed in my models.
The module looks like this:
Now in my models I can do this: