I was using form_for to create multiple objects on the same page. All of them were of the same active record class. Even tho I was using index on the form_for, it created several form blocks with the same id new_object_class. This patch adds the _#{index} to the id name if an index is specified…
Examples and patch are in the lighthouse ticket and includes the appropriate test case.
Ok, this is bizarre timing. I was thinking about this problem last night, and I “dream-coded” that I suffixed ALL id fields with: (object.respond_to?(:to_param) and ( id = object.to_param ) ? "#{_id}" : “” )
I wonder if there’s room in your patch for something feeding automatically from the object? As well as having the explicit option with the :index value, perhaps you could also accept :index => true and use .to_param of the object in question in that case?
Yes, of course, you’re right. I had been thinking of the edit scenario in fields_for (which I think would be cool if it did what I suggested when passed true). The excitement of the coincidence confused me, and I didn’t really read properly that you were talking about new objects.
+1 on your patch. It makes sense to be consistent between that and what is already done in tags.