Specify HTML options on select_year

Rails 1.2.3

It appears that the select_year helper doesn’t accept HTML attributes as
part of the options array.

Does anyone have a way to successfully pass an :onchange attribute in to
the select_year helper?

I’m going to do it with Javascript directly for now.

Thanks,
Wes

Hi Wes,

Please could you post the snippet of view code you are using? cheers

Jabbslad

On Feb 26, 7:32 am, Wes G. [email protected]

Here’s an example:

<%= select_year(DateTime.now.year, :start_year => 1960, :end_year =>
DateTime.now.year, :prefix => “school”, :field_name => “yearfrom”,
:include_blank => true) %>

If you read the source code for select_year carefully
(api.rubyonrails.org), you’ll see that any regular HTML options do not
get passed to the “select_html” call, just option tag values and
“select_html” - specific options (which are not HTML options).

I ended up using Prototype to set up the onchange handlers dynamically,
which, as it turns out, is a better practice, and was actually better
suited for what I was doing.

Thanks,
Wes