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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 18 Jan 2009, at 12:04, Phlip wrote:> > 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> I think this error is similar to a mismatched <td> situation, where > the browser > just throws away the incorrect cell... > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> On 18 Jan 2009, at 12:04, Phlip wrote: > >> > IIRC tr elements can only contain td elements. You can''t put a form > there. > > FredFred - I suppose you''re right. I tried changing this: <tr> <% 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 -%> </tr> to this (simple table row): <tr> <td>one</td> <td>two</td> <td>three</td> </tr> and it worked.. Is there no way to render anything other than <td/th> tags inside <tr> ? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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> On Jan 18, 5:39 am, Shilo Ayalon <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Frederick Cheung wrote: > > On 18 Jan 2009, at 12:04, Phlip wrote: > > > IIRC tr elements can only contain td elements. You can''t put a form > > there. > > > Fred > > Fred - I suppose you''re right. I tried changing this: > > <tr> > <% 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 -%> > </tr> > > to this (simple table row): > > <tr> > <td>one</td> > <td>two</td> > <td>three</td> > </tr> > > and it worked.. Is there no way to render anything other than <td/th> > tags inside <tr> ? > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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> On Jan 18, 5:38 am, Shilo Ayalon <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> 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 > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I don''t believe that form is valid between table and tr either. 2009/1/19 klochner <klochner-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> > 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> > > > > > > On Jan 18, 5:38 am, Shilo Ayalon <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > > 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 > > > > -- > > Posted viahttp://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---