Form doesn't appear in the view.. why?

Hi - I have a strange thing happening in my app. I'm trying to replace a
table row with a form row using link_to_remote and form_for. In my index
view I have a call to edit:

<%= link_to_remote 'edit vendor', :url => { :action => 'edit_vendor' }
%>

This works on a partial (_vendor.html.erb):

<% @vendor = vendor %>
<tr id="vendor_<%= vendor.id %>">
  <% unless edit_mode -%>
    <td><%= h vendor.name %></td>
    <td><%= h vendor.location %></td>
  <% else -%>
    <% form_for :vendor do |f| -%>
      <td><%= f.text_field :name, :size => 15 %></td>
      <td><%= f.text_field :location, :size => 15 %></td>
      <td><%= f.submit 'save' %></td>
    <% end -%>
  <% end -%>
</tr>

and finally I have a js template that adds the edit row and removes the
original one
(edit_vendor.js.rjs):

page.insert_html :after, 'vendor_3',
                 :partial => 'vendor',
                 :object => Vendor.find(3), :locals => { :edit_mode =>
true }

page.remove 'vendor_3'

I just tried testing with vendor_3 to see if this works. The action
generates the form in the page source, but it isn't visible on the
actual page. I can see the form tag using firebug (it appears faded, as
though display:none -- when it's not), but for some reason which eludes
me, it's invisible in the browser:

<tr id="vendor_3">
  <form method="post" action="/vendors/edit_vendor">
    <div style="margin: 0pt; padding: 0pt;"/>
    <input type="hidden"
value="248d3190ffb7dc764601dce231cd669054914fc5"
           name="authenticity_token"/>
    <td><input type="text" value="Vendor 1" size="15"
name="vendor[name]"
               id="vendor_name"/></td>
    <td><input type="text" value="New York" size="15"
name="vendor[location]"
               id="vendor_location"/></td>
    <td><input type="submit" value="save" name="commit"
id="vendor_submit"/></td>
  </form>
</tr>

I checked and it doesn't have any other visibility css rules and such...
Any clues what's happening?

Attachments:
http://www.ruby-forum.com/attachment/3169/invisible.png

Shilo Ayalon wrote:

    <% form_for :vendor do |f| -%>
      <td><%= f.text_field :name, :size => 15 %></td>
      <td><%= f.text_field :location, :size => 15 %></td>

Don't forms automatically have 'display: block;' style? Meaning you can't nest them between <table><tr><td> blocks?

I think this error is similar to a mismatched <td> situation, where the browser just throws away the incorrect cell...

Shilo Ayalon wrote:

   <% form_for :vendor do |f| -%>
     <td><%= f.text_field :name, :size => 15 %></td>
     <td><%= f.text_field :location, :size => 15 %></td>

Don't forms automatically have 'display: block;' style? Meaning you
can't nest
them between <table><tr><td> blocks?

IIRC tr elements can only contain td elements. You can't put a form
there.

Fred

Try this

<tr>
  <td colspan="3">
    <% form_for :vendor do |f| -%>
      <%= f.text_field :name, :size => 15 %>
      <%= f.text_field :location, :size => 15 %>
      <%= f.submit 'save' %>
    <% end -%>
  </td>
</tr>

or the following should work, although I'd consider just writing a
different
partial (_edit_vendor) to render the <% else %> block, and I'd also
just duplicate the closing </tr> in each block, trading an extra
line of code for a self-contained table row.

<% unless edit_mode -%>
  <tr id="vendor_<%= vendor.id %>">
    <td><%= h vendor.name %></td>
    <td><%= h vendor.location %></td>

  <% else -%>
    <% form_for :vendor do |f| -%>
    <tr id="vendor_<%= vendor.id %>">
      <td><%= f.text_field :name, :size => 15 %></td>
      <td><%= f.text_field :location, :size => 15 %></td>
      <td><%= f.submit 'save' %></td>
    <% end -%>
  <% end -%>
</tr>

I don’t believe that form is valid between table and tr either.