I’ve been to the RoR api docs trying to find out
about options for various methods (mostly for
select helper methods), yet I find no listing of
options even when the method described says
that it takes options. How
can I find out what are valid
options say for a date_select tag?
I’ve been to the RoR api docs trying to find out
about options for various methods (mostly for
select helper methods), yet I find no listing of
options even when the method described says
that it takes options. How
can I find out what are valid
options say for a date_select tag?
Dave,
In many places it’s not obvious, but in the example that you gave
(date_select), a careful reading of the documentation provides the
answer.
It's possible to tailor the selects through the options hash, which
accepts all the keys that each of the individual select builders do
(like :use_month_numbers for select_month) as well as a range of
discard options. The discard options are :discard_year, :discard_month
and :discard_day.
Also, notice at the top of the page the following:
All of the select-type methods share a number of common options that
are as follows:
* :prefix - overwrites the default prefix of "date" used for the
select names. So specifying “birthday” would give birthday[month]
instead of date[month] if passed to the select_month method.
* :include_blank - set to true if it should be possible to set an
empty date.
* :discard_type - set to true if you want to discard the type part
of the select name. If set to true, the select_month method would use
simply “date” (which can be overwritten using :prefix) instead of
“date[month]”.
Yep, Todd, it did. I must have been blind when I
went to that page. I think I was looking for something
else at the time, and the options issue raised it’s
ugly head later. Sorry for being asleep. I’ll learn to read
better next time.
I find that looking at the source sometimes helps when the docs do let
me down though. That’s a bit hit-and-miss too though, because
sometimes I have to look through quite a lot of source to work stuff
out.
-Nathan
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.