2009/6/19 James Byrne <[email protected]>:
>
> I am writing a test suite which depends upon begin able to use the html
> id attribute so that the tests are display language independent.  The
> <option> tag supports this attribute.  In fact it supports, among
> others, the CLASS, DISABLED, ID, LABEL, SELECTED, STYLE, TITLE, and
> VALUE attributes.  What I cannot seem to discern from the select API is
> how to set the ID attribute on a specific option.
>
> The API refers to options_for_select but I cannot see from that how to
> accomplish what I desire.
>
> The specific case that I am dealing with involves a select box for yes
> or no.  The model attribute is a boolean.  I desire to have this sort of
> output from the form builder:
>
> <p>
>  <b>
>    <label class="input_box_label"
>             for="select_is_invoicable"
>              id="label_is_invoicable">
>       Issue Invoices in this Currency
>    </label>
>  </b>
>  <br/>
>    <select id="select_is_invoicable"
>          name="currency[is_invoicable]"
>          size="1"
>          title="May invoices be issued in this currency?">
>
>       <option value="true"
>                  id="invoicable_true>Yes</option>
>       <option value="false" selected="selected"
>                  id="invoicable_false">No</option>
>    </select>
> </p>
>
> I can get everything except the id="invoicable_true" and
> id="invoicable_false" against their specific options.
>
> Is this possible with the existing select form helper or needs be I roll
> my own?

Assuming I understand the issue correctly then to achieve this I use
f.select inside a form_for.  This takes an array of values and ids for
the options.  I must admit though that I use integer values for the id
values so whether this will work in the way you require I am not sure.

Colin

--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to