Hi, I''m rendering a form using form_for, and Rails (2.0.2) is automatically generating the _method tag for me. Great! But why would the Rails team decide to wrap the thing in a div tag? Here is the output I''m getting: <form action="/admin/content_blocks/1/publish" class="edit_content_block" id="PublishContentBlock" method="post"> <div style="margin:0;padding:0"><input name="_method" type="hidden" value="put" /></div> <input id="PublishContentBlock" name="commit" type="submit" value="Publish this Content Block" /> </form> This is my code used to generate that: <% form_for object, :url=>publish_admin_content_block_path(@object), :html=>{:id=>''PublishContentBlock''} do |f| %> <%== submit_tag ''Publish this Content Block'', :id=>''PublishContentBlock'' %> <% end %> I need to display a button that''s in a different form, but have the button appear next to (after, inline) the previous forms buttons. How can I do this is the styles are hard-coded into the div tag that wraps the hidden _method tag? Matt --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
stephen.celis-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Jan-12 19:30 UTC
Re: form_for hidden _method input, wrapped in div?!
The ''div'' is there for HTML validation. This is not valid HTML: <form><input/></form> Input elements must be wrapped in another valid element. In this case, the Rails team used the generic ''div'' tag. You could still use CSS to position the two forms next to each other (specify, at least, a width, and float them both left). On Jan 12, 12:55 pm, goodieboy <goodie...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > I''m rendering a form using form_for, and Rails (2.0.2) is > automatically generating the _method tag for me. Great! But why would > the Rails team decide to wrap the thing in a div tag? Here is the > output I''m getting: > > <form action="/admin/content_blocks/1/publish" > class="edit_content_block" id="PublishContentBlock" method="post"> > <div style="margin:0;padding:0"><input name="_method" type="hidden" > value="put" /></div> > <input id="PublishContentBlock" name="commit" type="submit" > value="Publish this Content Block" /> > </form> > > This is my code used to generate that: > > <% form_for > object, :url=>publish_admin_content_block_path(@object), :html=>{:id=>''PublishContentBlock''} > do |f| %> > <%== submit_tag ''Publish this Content > Block'', :id=>''PublishContentBlock'' %> > <% end %> > > I need to display a button that''s in a different form, but have the > button appear next to (after, inline) the previous forms buttons. How > can I do this is the styles are hard-coded into the div tag that wraps > the hidden _method tag? > > Matt--~--~---------~--~----~------------~-------~--~----~ 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 ran into this ''div'' with the hidden field recently. First, <form><input/><form> is absolutely valid xhtml transitional. It''s only invalid if you''re using strict. Even if you are using strict, wrapping a hidden field in a div shows a poor understanding of semantic markup; a div is a generic block-level container for grouping content. If you must wrap the input to validate, fieldset is far more appropriate as a way of grouping form controls. As for positioning, CSS is the appropriate choice. On Jan 12, 12:30 pm, "stephen.ce...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <stephen.ce...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> The ''div'' is there for HTML validation. This is not valid HTML: > > <form><input/></form> > > Input elements must be wrapped in another valid element. In this case, > the Rails team used the generic ''div'' tag. > > You could still use CSS to position the two forms next to each other > (specify, at least, a width, and float them both left). > > On Jan 12, 12:55 pm, goodieboy <goodie...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi, > > > I''m rendering a form using form_for, and Rails (2.0.2) is > > automatically generating the _method tag for me. Great! But why would > > the Rails team decide to wrap the thing in a div tag? Here is the > > output I''m getting: > > > <form action="/admin/content_blocks/1/publish" > > class="edit_content_block" id="PublishContentBlock" method="post"> > > <div style="margin:0;padding:0"><input name="_method" type="hidden" > > value="put" /></div> > > <input id="PublishContentBlock" name="commit" type="submit" > > value="Publish this Content Block" /> > > </form> > > > This is my code used to generate that: > > > <% form_for > > object, :url=>publish_admin_content_block_path(@object), :html=>{:id=>''PublishContentBlock''} > > do |f| %> > > <%== submit_tag ''Publish this Content > > Block'', :id=>''PublishContentBlock'' %> > > <% end %> > > > I need to display a button that''s in a different form, but have the > > button appear next to (after, inline) the previous forms buttons. How > > can I do this is the styles are hard-coded into the div tag that wraps > > the hidden _method tag? > > > Matt--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---