views:

164

answers:

1

Hi Everyone,

I have a date_select field in my rails application as follows:

<%= f.date_select :dateinstructed %>

I would like to re-order the drop down lists show they output as:

DD/MM/YYYY

According to what I have read you can use the :order option, but I am unsure how to actually use this option:

<%= f.date_select :dateinstructed, :order = {:day, :month, :year} %>

Obviously this isn't right, but what am I supposed to put in place of the:

:day, :month, :year

Any help would be appreciated!

Thanks,

Danny

+2  A: 

I think it should be:

<%= f.date_select :dateinstructed, :order => [:day, :month, :year] %>

Hopefully it helps.

SamChandra
Reffer http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#M001698
Salil
I think I love you! Thanks :)
dannymcc
Thanks, the reason I couldn't get it working was this line of the API link you showed me:date_select(object_name, method, options = {}, html_options = {})I was using options = {} not options = []
dannymcc
Well, not really... You were using `options = {}` but it was hidden from you. The form helper functions in rails will assume all the parameters passed after the required parameters to be a hash unless both the options and html_options are implicitly passed in. So in your case, after rails does it's parameter fun tricks, you are passing this `f.date_select :dateinstructed, { :order => [:day, :month, :year] }, {}`. That is why, when you want html options you have to close the options in curly braces ({}).
Tony Fontenot