This project is archived and is in readonly mode.
Incorrect input name with nested fields_for
Reported by David Röthlisberger | May 13th, 2008 @ 04:36 PM | in 2.x
form_for('post[]', @post) do |f|
f.fields_for('comment[]', @comment) do |c|
c.text_field(:name)
end
end
I expect:
<input name="post[123][comment][][name]" .../>
Instead I get:
<input name="post[][comment[]][name]" .../>
Comments and changes to this ticket
-
David Röthlisberger May 13th, 2008 @ 04:40 PM
- no changes were found...
-
josh July 17th, 2008 @ 01:36 AM
- Milestone set to 2.x
- Assigned user set to josh
- Tag set to actionpack
I think that should be the correct behavior. Can you get me a fix too. If not, I'll try to tackle it as well.
-
David Röthlisberger July 17th, 2008 @ 02:01 AM
I am swamped under at the moment, and the rails internals are still black magic to me, so it'll be at least a month before I get around to trying to fix it.
If you can tackle it go ahead, I appreciate it. :)
In the meantime I have worked around the problem by specifying the input name manually, i.e.
fields_for('post[123][comment][]')
instead of
f.fields_for('comment[]')
-
josh July 19th, 2008 @ 01:45 AM
The state of form helpers like this feels very hackish.
I think we should analysis some current patterns and refactor it all.
-
Clemens Kofler July 19th, 2008 @ 11:46 AM
Joshua: I've started refactoring the helpers in my Rails fork at github.com/clemens/rails. There's also a topic in the mailing list (http://groups.google.com/group/r...).
FormHelper is definitely on my list, too. There's also relevant topics here and here
-
RSL July 19th, 2008 @ 01:10 PM
There's been some changes to how index is handled as well. http://rails.lighthouseapp.com/p... has test coverage for indexes on the fields_for. Might be good to mix that in too?
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>