date_select helper with_css_classes option also accept a hash #24225
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hey! It's my first PR to rails. Please, be nice 😉
Research/History
With #7975 the
:with_css_classes
option was added to thedate_select
helper.This option automatically set generic classes 'year', 'month', 'day', 'hour', 'minute' and 'second' for your 'select' tags. For example:
Select groups get their generic class. CSS rules can be specified. Nice, but not perfect.
Improvement
Sometimes select tags get some love and receive nice styling. If only one select element
must contain a custom css classes this was hard to achieve.
Instead of an boolean value pass a hash of strings for
:year
,:month
,:day
,:hour
,:minute
,:second
towith_css_classes
. This will extend the select type with the given value.Similar how
:prompt
is doing this.Optional, add global
html_options
to modify every select tag in the set.The hash for
with_css_classes
can applied to DateHelper methods:select_day
select_month
select_year
select_hour
select_minute
select_second
select_datetime
select_time
date_select
time_select
datetime_select
The were missing tests for
with_css_classes
, I'd tried to cover.🍀