Lee
Lee

Reputation: 9462

Rails: Change default format of the date_select helper?

How can I change the default order of the date_select helper?

Upvotes: 1

Views: 4633

Answers (2)

Sergey Chechaev
Sergey Chechaev

Reputation: 570

view

date_select("set_date", "written_on", :order => [:year, :month])

controller

date = (params[:set_date])? params[:set_date] : DateTime.now
date = date.to_a.sort.collect{|c| c[1]}.join("-")

Upvotes: 2

Simone Carletti
Simone Carletti

Reputation: 176362

The helper offers a limited set of options. If you want to apply further customizations, you need to create your own.

Upvotes: 1

Related Questions