# Difficulty with params hash and submit\_to\_remote

**URL:** <https://www.ruby-forum.com/t/difficulty-with-params-hash-and-submit-to-remote/78499>\
**Category:** Rails\
**Created:** [March 8, 2006, 5:05pm UTC](https://www.ruby-forum.com/t/difficulty-with-params-hash-and-submit-to-remote/78499 "2006-03-08T17:05:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stan\_McFarland](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ecae2f/32.png) [@Stan\_McFarland](https://www.ruby-forum.com/u/Stan_McFarland)\
**Post date:** [March 8, 2006, 5:05pm UTC](https://www.ruby-forum.com/t/difficulty-with-params-hash-and-submit-to-remote/78499/1 "2006-03-08T17:05:56Z")

</div>

Hi,

Is there any trick to initializing the params hash via  
submit\_to\_remote()? I  
have a form with two submit methods - the regular, non-AJAX method, and  
the  
AJAX method. The regular method works like a champ. The  
submit\_to\_remote  
invokes the correct controller, but the params hash is empty except for  
the  
values for :action and :controller.

I’d show my code, but it’s on an internal network and I can’t  
cut-and-paste.

Thanks,

-stan

---

<div class="post-metadata">

**Author:** ![Stan\_McFarland](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ecae2f/32.png) [@Stan\_McFarland](https://www.ruby-forum.com/u/Stan_McFarland)\
**Post date:** [March 8, 2006, 5:51pm UTC](https://www.ruby-forum.com/t/difficulty-with-params-hash-and-submit-to-remote/78499/2 "2006-03-08T17:51:54Z")

</div>

Nothing magic here, just add the other parameters to the remote\_function  
or link\_to\_remote calls like this…

\<%= link\_to\_remote “Link”, :update=\>‘updatediv’,  
:controller=\>‘controller’, :action=\>'action", :id=\>object.id, :other  
=\>‘other stuff’ %\>

Things like other should now be in the params array for the recieving  
action

\_Kevin

---

<div class="post-metadata">

**Author:** ![Stan\_McFarland](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ecae2f/32.png) [@Stan\_McFarland](https://www.ruby-forum.com/u/Stan_McFarland)\
**Post date:** [March 8, 2006, 7:19pm UTC](https://www.ruby-forum.com/t/difficulty-with-params-hash-and-submit-to-remote/78499/3 "2006-03-08T19:19:57Z")

</div>

Kevin O. wrote:

> Nothing magic here, just add the other parameters to the remote\_function  
> or link\_to\_remote calls like this…

ok, I’m confused (but I _am_ a newbie!). I thought the whole idea with  
submit\_to\_remote() was to make the contents of a form available to the  
controller in the params hash, just as if I had submitted it via  
non-AJAX form. Otherwise, I could have just called link\_to\_remote()  
instead.

Any suggestions?

---

<div class="post-metadata">

**Author:** ![Stan\_McFarland](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ecae2f/32.png) [@Stan\_McFarland](https://www.ruby-forum.com/u/Stan_McFarland)\
**Post date:** [March 8, 2006, 8:21pm UTC](https://www.ruby-forum.com/t/difficulty-with-params-hash-and-submit-to-remote/78499/4 "2006-03-08T20:21:53Z")

</div>

Kevin,

Thanks. Believe it or not, it was a missing tag in the view that  
was preventing the form values from being passed.

-stan

Kevin O. wrote:

> It would help if I actually read your question right.
> 
> Take a close look at the API for submit\_to\_remote… if you also read  
> the docs for form\_remote\_tag. This indicates that there is a way to set  
> it up to fallback to a normal submit if JS is disabled. You shouldn’t  
> need wo submit mechanisms.
> 
> I haven’t actually used this yet, so I can’t help much more than that.
> 
> \_Kevin

---

<div class="post-metadata">

**Author:** ![Stan\_McFarland](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ecae2f/32.png) [@Stan\_McFarland](https://www.ruby-forum.com/u/Stan_McFarland)\
**Post date:** [March 8, 2006, 8:13pm UTC](https://www.ruby-forum.com/t/difficulty-with-params-hash-and-submit-to-remote/78499/5 "2006-03-08T20:13:40Z")

</div>

It would help if I actually read your question right.

Take a close look at the API for submit\_to\_remote… if you also read  
the docs for form\_remote\_tag. This indicates that there is a way to set  
it up to fallback to a normal submit if JS is disabled. You shouldn’t  
need wo submit mechanisms.

I haven’t actually used this yet, so I can’t help much more than that.

\_Kevin

---

<div class="post-metadata">

**Author:** ![Stan\_McFarland](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ecae2f/32.png) [@Stan\_McFarland](https://www.ruby-forum.com/u/Stan_McFarland)\
**Post date:** [January 12, 2007, 11:42am UTC](https://www.ruby-forum.com/t/difficulty-with-params-hash-and-submit-to-remote/78499/6 "2007-01-12T11:42:57Z")

</div>

Hi guys,

i’ve got the same problem. But in my situation I have to send values of  
text-inputs via submit\_to\_remote() to my controller. I don’t know how to  
get the value of this text-input:  
\<%= text\_field\_with\_auto\_complete(:vorgang, :bez, {:value =\> ‘\*\*\*\*’},  
{:skip\_style =\> true} ) %\>

to my controller:

def filterDatensatz()  
tmp = params[:vorgang][:bez]  
my\_redirect\_to(:action =\> ‘list’, :tmp =\> tmp)  
end

params[:vorgang] is always nil.

Can you help me?

Greetings  
Chris

---

<div class="post-metadata">

**Author:** ![Stan\_McFarland](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ecae2f/32.png) [@Stan\_McFarland](https://www.ruby-forum.com/u/Stan_McFarland)\
**Post date:** [January 19, 2007, 4:31pm UTC](https://www.ruby-forum.com/t/difficulty-with-params-hash-and-submit-to-remote/78499/7 "2007-01-19T16:31:02Z")

</div>

try something like this:

rhtml:  
\<%= text\_field\_with\_auto\_complete :person, :nachname, {},  
{  
:select =\> ‘name’,  
:after\_update\_element =\>  
“function(element,value) " +  
“{ " +  
remote\_function(:update=\>‘Kundendaten’,  
:url=\>{:action=\>:update\_kundendaten},  
:with=\>”‘adr\_id=’+value.id”) + “;” +  
“}”  
}  
%\>

controller:  
def update\_kundendaten  
#params[:adr\_id] should be ok in controller  
end

but with this solution i have the problem that the autocomplete is only  
working on IE.  
FF wont show the autocomplete popup. ☹

HTH

On 12 Jan., 11:42, Christian R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
