An enhanced date select form helper that allows you to use the full HTML specification for date_select helper methods from rails. This is more than what you get with the default Rails date select helper because it can allow values to persist in dropdowns even if you submit a invalid value.
- Fully customizable HTML5 attributes for date_select .
-
Rails >= 4.0 only. MRI >= 2.2.0
-
JRuby is not offically supported.
We will accept further compatibilty pull-requests but no upcoming versions will be tested against it.
Rubinius support temporarily dropped due to Rails 4 incompatibility.
Type the following from the command line to install:
gem install enhanced_date_select
Add the following to your Gemfile:
gem "enhanced_date_select"
Use the enhanced_date_select instead of date_select helper methods in your views. Example:
form.enhanced_date_select :birthday,
{
:prompt =>
{
:day => "please select one",
:month => "please select one",
:year => "please select one"
},
:value =>
{
:year => @year,
:month => @month,
:day => @day
},
:order => [:day, :month, :year],
:start_year => Time.now.year,
:end_year => 1940
},
{
:class => "input_3cols"
}
...or alternatively:
form.enhanced_date_select :birthday,
{
:prompt =>
{
:day => "please select one",
:month => "please select one",
:year => "please select one"
},
:value => Date.new(2011,02,01),
:order => [:day, :month, :year],
:start_year => Time.now.year,
:end_year => 1940
},
{
:class => "input_3cols"
}
The enhanced_date_select takes all the standard options as the default Rails date_select method. The only difference is that it expects an hash with values for year, month and day instead of an date object.
To test, do the following:
- cd to the gem root.
- bundle install
- bundle exec rake
Contributions
Please log all feedback/issues via Github Issues. Thanks.
- Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
- Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
- Fork the project.
- Start a feature/bugfix branch.
- Commit and push until you are happy with your contribution.
- Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
- Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
Copyright (c) 2012 bogdanRada. See LICENSE.txt for further details.