# Problem with form\_remote\_tag and hidden fields

**URL:** <https://www.ruby-forum.com/t/problem-with-form-remote-tag-and-hidden-fields/123893>\
**Category:** Rails\
**Created:** [December 21, 2007, 8:19pm UTC](https://www.ruby-forum.com/t/problem-with-form-remote-tag-and-hidden-fields/123893 "2007-12-21T20:19:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![acampos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/919ad9/32.png) [@acampos](https://www.ruby-forum.com/u/acampos)\
**Post date:** [December 21, 2007, 8:19pm UTC](https://www.ruby-forum.com/t/problem-with-form-remote-tag-and-hidden-fields/123893/1 "2007-12-21T20:19:29Z")

</div>

I’m using form\_remote\_tag to generate a remote form that contains  
nothing but a hidden\_field\_tag and a submit\_tag. The form appears to  
be generated correctly (I see the tag and the field  
with type=“hidden” contained in it) and it’s submitted using Ajax to  
the correct URL, but the hidden field is not sent to the server. Is  
there any reason this shouldn’t work?

---

<div class="post-metadata">

**Author:** ![acampos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/919ad9/32.png) [@acampos](https://www.ruby-forum.com/u/acampos)\
**Post date:** [December 22, 2007, 3:59am UTC](https://www.ruby-forum.com/t/problem-with-form-remote-tag-and-hidden-fields/123893/2 "2007-12-22T03:59:33Z")

</div>

Quoting bigbanger [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> I’m using form\_remote\_tag to generate a remote form that contains  
> nothing but a hidden\_field\_tag and a submit\_tag. The form appears to  
> be generated correctly (I see the tag and the field  
> with type=“hidden” contained in it) and it’s submitted using Ajax to  
> the correct URL, but the hidden field is not sent to the server. Is  
> there any reason this shouldn’t work?

I am using this in Rails 1.2 and Rails 2.0 and it works fine. Here is  
the  
relevant code from my template:

```
<% form_remote_tag(:url=>{:controller=>'comments', :action=>'add'},
    :update=>"comments_#{show.id}", :position=>:bottom) do %>
  <%= hidden_field_tag('comment[task_id]', 0) %>
  <%= hidden_field_tag('comment[parent_id]', show.id) %>

  <%= submit_tag :reply.l %>
<% end %>

```

HTH,  
Jeffrey

---

<div class="post-metadata">

**Author:** ![acampos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/919ad9/32.png) [@acampos](https://www.ruby-forum.com/u/acampos)\
**Post date:** [December 23, 2007, 12:46am UTC](https://www.ruby-forum.com/t/problem-with-form-remote-tag-and-hidden-fields/123893/3 "2007-12-23T00:46:40Z")

</div>

Hmm, my code looks pretty much the same as yours (although I’m using  
RESTful routes). As I said, the HTML appears to be generated  
correctly, but for some reason the hidden field isn’t being serialized  
to the server in the Ajax request. I added a request parameter  
instead and that worked in the interim, but I’m not sure why the  
hidden field didn’t work…

On Dec 21, 6:59 pm, Jeffrey T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
