On 10/11/07, dw <tdtc-sicm-5+VhGm8TZF7QT0dZR+AlfA@public.gmane.org>
wrote:>
>
> 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.
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...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---