I have...
<%= select(:machine, :name, Machine.find(:all).map {|m| [m.name, m.id]},
{}, :class => "something" %>
This gives me....
<select class="something" id="machine_name"
name="machine[name]">
<option value="12">AZ01</option>
<option value="13">AZ02</option>
<option value="14">AZ03</option>
What I am looking for is....
<select id="machine_name" name="machine[name]">
<option class ="something"
value="12">AZ01</option>
<option class ="something"
value="13">AZ02</option>
<option class ="something"
value="14">AZ03</option>
How do you do this?
Thanks,
~Jeremy
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
You can swap the order of the name and id fields in the array to get the
right values and inner content in the option elements, but I don''t
think
there''s a convenient way to specify the CSS class of the option
elements.
You can either build the elements yourself (maybe with content_tag) or
add them using Javascript. It should be pretty easy to do with the
Prototype library (which is included in Rails by default). Try using
$$(''select.something'') to get the select element with the
class
"something", then addClassName("something") on each option
child
element.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---