Is it possible to use the :with option with remote_form_for?
It works with link_to_remote, and the api docs seems to indicate :with should work with any of the remote_ methods.
Here is the code I'm using, and output it's producing:
= link_to_remote 'ARGH', {:url => {:action => 'load_item', :id => @policy.id} , :with => "'elephant=mouse'"}
<a href="#" onclick="new Ajax.Request('http://localhost:3000/quote_edit/load_item/5', {asynchronous:true, evalScripts:true, parameters:'elephant=mouse' + '&authenticity_token=' + encodeURIComponent('o6whEDZLuq1b1NsuZXIlNjc3iudZNC8jU+ZxgUDXFUk=')}); return false;">arg</a>
= remote_form_for :policy, @policy, :url => {:action => 'load_item', :id => @policy.id} , :with => "'elephant=mouse'" do |f|
<form action="http://localhost:3000/quote_edit/load_item/5" method="post" onsubmit="new Ajax.Request('http://localhost:3000/quote_edit/load_item/5', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;">
Does anyone know how to make remote_form_for pick up on this option?
Or is it being ignored by remote_form_for as it needs to use parameters:Form.serialize(this)
to pick up the values from the current form?
Cheers Dave Smylie
I had the same problem when I wanted to use javascript to calculate the id of the url.
Researched the source code and determined that remote forms and submits don't seem to allow the :with statement to work.
I got around this using a hidden field called overridden_id on the form. Then in the :before option, I added javascript to set the hidden fields value.
Inside the controller I added "params[:overriden_id] || parmam[:id]" to my Find to override the default id passed into the url.