enhanced_date_select
Overview
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.
Features
- Fully customizable HTML5 attributes for date_select .
Requirements
- Ruby 1.9.x or Ruby 2.x.x
- Ruby On Rails
Compatibility
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.
Setup
Type the following from the command line to install:
gem install enhanced_date_select
Add the following to your Gemfile:
gem "enhanced_date_select"
Usage
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.
Testing
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.
Contributing to enhanced_date_select
- 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
Copyright (c) 2012 bogdanRada. See LICENSE.txt for further details.