# Remote\_form\_for not passing form values

**URL:** <https://www.ruby-forum.com/t/remote-form-for-not-passing-form-values/157262>\
**Category:** Rails\
**Created:** [January 8, 2009, 11:48pm UTC](https://www.ruby-forum.com/t/remote-form-for-not-passing-form-values/157262 "2009-01-08T23:48:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![hangingclowns](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b5e925/32.png) [@hangingclowns](https://www.ruby-forum.com/u/hangingclowns)\
**Post date:** [January 8, 2009, 11:48pm UTC](https://www.ruby-forum.com/t/remote-form-for-not-passing-form-values/157262/1 "2009-01-08T23:48:24Z")

</div>

I have the following:

\<% form\_remote\_for :role, :method =\> :put, :url =\> {:controller =\>  
“roles”, :action =\> “update”, :id =\> @role.id  
} do |f| %\>

 \<%= select("role", "default\_view", Account::ROLES) %\> \<%= submit\_tag("Update"); %\> 

 \<% end -%\>

Controller code:  
def update  
role = Role.find(params[:id])  
role.update\_attributes(params[:role])  
render :update do |page|  
logger.info "update: " + debug(params)  
end

the “debug(params)” outputs:

update:

```
— !map:HashWithIndifferentAccess
_method: put
action: update
id: “6”
controller: roles
```

There is no “default\_view” field from my drop down. Just the params  
passed on the URL string. Not sure why this is happening.

Thanks for any help

---

<div class="post-metadata">

**Author:** ![hangingclowns](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b5e925/32.png) [@hangingclowns](https://www.ruby-forum.com/u/hangingclowns)\
**Post date:** [January 9, 2009, 1:09am UTC](https://www.ruby-forum.com/t/remote-form-for-not-passing-form-values/157262/2 "2009-01-09T01:09:08Z")

</div>

I solved it: Don’t put your form tag under a

 tag. Argh.

---

<div class="post-metadata">

**Author:** ![hangingclowns](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b5e925/32.png) [@hangingclowns](https://www.ruby-forum.com/u/hangingclowns)\
**Post date:** [February 19, 2009, 3:52am UTC](https://www.ruby-forum.com/t/remote-form-for-not-passing-form-values/157262/3 "2009-02-19T03:52:41Z")

</div>

2009/1/9 Allen W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> I solved it: Don’t put your form tag under a
> 
> tag. Argh.
> 
> \*Is this a Rails bug? \*
> 
> Just hit the same issue, i.e. my field attributes were not being passed  
> within a “remote\_form\_for” that was within a table.
> 
> How is one supposed to work around this if you need an AJAX form call  
> within  
> part of a table, and the table is required for the existing layout of  
> the  
> page?

---

<div class="post-metadata">

**Author:** ![hangingclowns](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b5e925/32.png) [@hangingclowns](https://www.ruby-forum.com/u/hangingclowns)\
**Post date:** [February 19, 2009, 6:18am UTC](https://www.ruby-forum.com/t/remote-form-for-not-passing-form-values/157262/4 "2009-02-19T06:18:28Z")

</div>

2009/2/19 Greg H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> 2009/1/9 Allen W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
> 
> > I solved it: Don’t put your form tag under a
> > 
> > tag. Argh.
> > 
> > I see that you can put a form in a table, but it has to fit entirely  
> > within  
> > a table cell (not perfect answer, but better than not being able to use  
> > a  
> > table at all)

---

<div class="post-metadata">

**Author:** ![hangingclowns](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b5e925/32.png) [@hangingclowns](https://www.ruby-forum.com/u/hangingclowns)\
**Post date:** [February 20, 2009, 2:56am UTC](https://www.ruby-forum.com/t/remote-form-for-not-passing-form-values/157262/5 "2009-02-20T02:56:16Z")

</div>

No, it’s not a Rails bug - lrn2html. (ref:  
[http://www.w3.org/TR/html401/struct/tables.html#h-11.2.1](http://www.w3.org/TR/html401/struct/tables.html#h-11.2.1)  
)

Typically, one puts the table in the form, not the other way around.  
The HTML spec is pretty specific about what can go inside the table  
tag  
without being contained by a cell.

I’d also add, in reference to the original code, that you should be  
using  
f.select(:default\_view, Account::ROLES) - form\_for and friends pass  
the  
builder to the block.

–Matt J.

On Feb 19, 12:17 am, Greg H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![hangingclowns](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b5e925/32.png) [@hangingclowns](https://www.ruby-forum.com/u/hangingclowns)\
**Post date:** [February 20, 2009, 2:57pm UTC](https://www.ruby-forum.com/t/remote-form-for-not-passing-form-values/157262/6 "2009-02-20T14:57:36Z")

</div>

On 20 Feb 2009, at 10:52, Greg H. wrote:

> fair enough - interesting through things worked fine with  
> “form\_for”, and it was just when moving to “remote\_form\_for” the  
> issue kicked in…

Probably because with remote\_form\_for the serialization happens in  
javascript. You’re going down a different codepath and so the  
undefined behaviour may be different.

Fred

---

<div class="post-metadata">

**Author:** ![hangingclowns](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b5e925/32.png) [@hangingclowns](https://www.ruby-forum.com/u/hangingclowns)\
**Post date:** [February 20, 2009, 11:53am UTC](https://www.ruby-forum.com/t/remote-form-for-not-passing-form-values/157262/7 "2009-02-20T11:53:18Z")

</div>

fair enough - interesting through things worked fine with “form\_for”,  
and it  
was just when moving to “remote\_form\_for” the issue kicked in…

2009/2/20 Matt J. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> I’d also add, in reference to the original code, that you should be
> 
> >

–  
Greg  
[http://blog.gregnet.org/](http://blog.gregnet.org/)
