# Form\_for hidden \_method input, wrapped in div?!

**URL:** <https://www.ruby-forum.com/t/form-for-hidden-method-input-wrapped-in-div/125848>\
**Category:** Rails\
**Created:** [January 12, 2008, 7:57pm UTC](https://www.ruby-forum.com/t/form-for-hidden-method-input-wrapped-in-div/125848 "2008-01-12T19:57:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![goodieboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ecc23a/32.png) [@goodieboy](https://www.ruby-forum.com/u/goodieboy)\
**Post date:** [January 12, 2008, 7:57pm UTC](https://www.ruby-forum.com/t/form-for-hidden-method-input-wrapped-in-div/125848/1 "2008-01-12T19:57:11Z")

</div>

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:

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

---

<div class="post-metadata">

**Author:** ![goodieboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ecc23a/32.png) [@goodieboy](https://www.ruby-forum.com/u/goodieboy)\
**Post date:** [January 12, 2008, 8:31pm UTC](https://www.ruby-forum.com/t/form-for-hidden-method-input-wrapped-in-div/125848/2 "2008-01-12T20:31:49Z")

</div>

The ‘div’ is there for HTML validation. This is not valid HTML:

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).

---

<div class="post-metadata">

**Author:** ![goodieboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ecc23a/32.png) [@goodieboy](https://www.ruby-forum.com/u/goodieboy)\
**Post date:** [March 11, 2008, 7:04pm UTC](https://www.ruby-forum.com/t/form-for-hidden-method-input-wrapped-in-div/125848/3 "2008-03-11T19:04:22Z")

</div>

I ran into this ‘div’ with the hidden field recently. First,

 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, “removed\_email\_address@domain.invalid”
