Forum: Ruby on Rails remote_form_for not passing form values

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Allen W. (Guest)
on 2009-01-09 00:48
I have the following:

<% form_remote_for :role, :method => :put, :url => {:controller =>
"roles", :action => "update", :id => @role.id\
}  do |f| %>
  <tr>
    <td><%= select("role", "default_view", Account::ROLES) %></td>
    <td><%= submit_tag("Update"); %> </td>
    <td>
      <div id="role_attributes">
      </div>
    </td>
  </tr>
<% 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: <pre class='debug_dump'>--- !map:HashWithIndifferentAccess
_method: put
action: update
id: &quot;6&quot;
controller: roles
</pre>


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
Allen W. (Guest)
on 2009-01-09 02:09
I solved it: Don't put your form tag under a <table> tag. Argh.
Greg H. (Guest)
on 2009-02-19 04:52
(Received via mailing list)
2009/1/9 Allen W. <removed_email_address@domain.invalid>

>
> I solved it: Don't put your form tag under a <table> 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?
Greg H. (Guest)
on 2009-02-19 07:18
(Received via mailing list)
2009/2/19 Greg H. <removed_email_address@domain.invalid>

> 2009/1/9 Allen W. <removed_email_address@domain.invalid>
>
>>
>> I solved it: Don't put your form tag under a <table> 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)
Matt J. (Guest)
on 2009-02-20 03:56
(Received via mailing list)
No, it's not a Rails bug - lrn2html. (ref:
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>
Greg H. (Guest)
on 2009-02-20 12:53
(Received via mailing list)
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>

> I'd also add, in reference to the original code, that you should be
> >
>
--
Greg
http://blog.gregnet.org/
Frederick C. (Guest)
on 2009-02-20 15:57
(Received via mailing list)
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
This topic is locked and can not be replied to.