select with :multiple => true

Hello,

Currently when using the select_tag method with the :multiple => true
option the name parameter is set as is.

select_tag "access", nil, :multiple => true
  # => <select id="access" multiple="multiple" name="access"></select>

Although for the mulitple values to be sent the name should instead be
"access[]".

So you can do that with the following...

select_tag "access", nil, :name => "access[]", :multiple => true
  # => <select id="access" multiple="multiple" name="access[]"></select>

Should this be set automatically where the method checks for the
:multiple option as true and sets the name to "access[]"?

So with :multiple => true...

select_tag "access", nil, :multiple => true
  # => <select id="access" multiple="multiple" name="access[]"></select>

and without :multiple => true...

select_tag "access", nil
  # => <select id="access" multiple="multiple" name="access"></select>

Thanks

Should this be set automatically where the method checks for the
:multiple option as true and sets the name to "access[]"?

So with :multiple => true...

select_tag "access", nil, :multiple => true
# => <select id="access" multiple="multiple" name="access[]"></select>

and without :multiple => true...

select_tag "access", nil
# => <select id="access" multiple="multiple" name="access"></select>

This sounds like a nice enhancement, you should have a go at it and
send in a patch. There are instructions here:

http://rails.lighthouseapp.com/projects/8994/sending-patches

Good luck :slight_smile:

I'll make a patch. I just wanted to know if it was worth doing.

Thanks

Patch submitted...
http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/1146

Thanks