I have a scenario where I need to include an ajax form within another ajax form to allow a user to select a photo to save. It seems I need to use form_remote_tag with link_to_remote to submit it within a remote_form_for. The inner form_remote_tag now works, but now the outer remote_form_for does not work. This is what I have:
<% remote_form_for [@list, @term] do |f| %>
<div id="upload_image" onclick="$('image_upload_form').show()">upload image</div>
<div id="image_upload_form" style="display:none">
<div id="flickr_search">
<% form_remote_tag(:url => { :controller => "images", :action => "flickr_search" }) do %>
<%= text_field_tag :keywords %>
<%= link_to_remote "save", :url => {:controller => "images", :action => "flickr_search" }, :submit => "flickr_search" %>
<% end %>
</div>
</div>
<%= f.text_area :definition, :size => "33x3", :class => "textarea", :id => "definition" %>
<%= f.submit "Save" %>
<% end %>
Anyone have any ideas on how I can get these two forms to play well together?
A form with in a form is not valid html and should be avoided. It will cause you all kinds of issues (if you can get it to work at all).
I am guessing you could probably replace your inner form with some JavaScript/ajax that provides the same functionality without the form tags. (Think ajax request triggered on click which opens an overlay window that does your flickr searching then puts the image url in the field in the form.)
You could also think about making it a two step processes.
Good luck