This project is archived and is in readonly mode.

#145 ✓duplicate
David Röthlisberger

collection_select doesn't honour :index option to fields_for

Reported by David Röthlisberger | May 8th, 2008 @ 05:31 PM

If I do

fields_for :post, @post, :index => 1 do |f|
  f.collection_select(:author_name, @posts, :author_name, :author_name)
end

I get

<select name="post[author_name]" ... >

Instead of the expected

<select name="post[1][author_name]" ... >

Without specifying index, it works correctly, i.e.

fields_for 'post[]', @post do |f|

does generate the correct <select name="post[1][author_name]"

The other helpers (text_field, checkbox etc) do work correctly with the :input option.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Attachments

Referenced by

Pages