Grouped Select in Rails

Posted by Neil Middleton on Stack Overflow See other posts from Stack Overflow or by Neil Middleton
Published on 2009-07-28T09:02:23Z Indexed on 2010/06/08 16:02 UTC
Read the original article Hit count: 265

Filed under:
|

Simple question really - how do I use the select(ActionView::Helpers::FormOptionsHelper) with grouped options?

I have got it working with a select_tag (ActionView::Helpers::FormTagHelper) but I would really like to have it using a select tag to match the rest of the form. Is this possible?

My options look like this:

[
  ['Group 1', ["Item 1", "Item 2", "Item 3"]],
  ['Group 2',["Item 1", "Item 2", "Item 3", "Item 4"]]
]

whilst my view is currently:

%tr#expense
  %td
    = f.text_field :value
    = f.hidden_field :type, :value => mode

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby