سؤال

I would like to have my date select fields default to "Select month", "Select dat", and "Select year"

I've read that you can not combine default with prompt because default doesn't recognize prompt. I'm using Bootstrap but I don't believe that is very relevant.

This code does add "Select day", etc to the options but it is defaulting to nil since that what my user's birthdate is at the time of the form.

Is there a straightforward solution? Seems like a common problem.

        <%= ff.date_select :birth_date, prompt: true, 
        :prompt => { :day => 'Select day', :month => 'Select month', :year => 'Select year' },
        include_blank: true, 
        :default => {:year=>"Select year", :month=>"Select month", :day=>"Select day"} %>
هل كانت مفيدة؟

المحلول

You cannot use the prompt twice, as one is enough. Try this and let me know.

<%= ff.date_select :birth_date,:prompt => { :day => 'Select day', :month => 'Select month', :year => 'Select year' }  %>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top