Multiple forms for same model - DOM id collision?

I’m hoping someone can point me to what the “best practice” is…

The basic scenario is a page with two AJAX forms for the same model.
One is
to create a new object, while another is to edit an existing object of
the
same model. For example, if you had a social networking site, you might
have a page where you can edit your school information as well as add
school
information.

The problem I’m running into is that if I use form_for, I end up with
two
forms whose children have the same DOM ids. I know I can avoid this by
using form tag helpers like text_field_tag, but I’m wondering if there
is a
more elegant solution to this problem.

It seems like this would be a fairly common issue, but for some reason I
can’t find anything about it.

Thanks!

View this message in context:
http://www.nabble.com/Multiple-forms-for-same-model---DOM-id-collision--tf4609106.html#a13161720
Sent from the RubyOnRails Users mailing list archive at Nabble.com.

On 10/11/07, dw [email protected] wrote:

The problem I’m running into is that if I use form_for, I end up with two
forms whose children have the same DOM ids. I know I can avoid this by
using form tag helpers like text_field_tag, but I’m wondering if there is a
more elegant solution to this problem.

It seems like this would be a fairly common issue, but for some reason I
can’t find anything about it.

What I’ve done is to use different object names in form_remote_for,
and then pass that name as a parameter on the form url, so I can point
to the right parameter to pick up the values in the controller. Kind
of sub-elegant, but it works and it’s not too difficult to code up.
You could even dispense with the extra parameter and just hunt through
the params hash looking for a prefix.

It would be nice the the form builder let you specify an id prefix…