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.

Hi,
I have the following form_for tag that seems to be outputing <div
style="margin:0;padding:0"> any suggestions on how this can be stopped?
<% form_for :user, :url => user_path(@user), :html => {:method => :put}
do |f| %>
cheers
jon

Perhaps it adds the div due to compatibility with XHTML? I'm new here,
and quite new to Ruby on Rails too, but it seems fairly reasonable that
that's what RoR is doing.
One must put a blocking object inside a form for it to be valid XHTML.
Valid:
<form method="post" action="/somewhere">
<div>
<input type="text" name="something" id="something" />
</div>
</form>
Invalid:
<form method="post" action="/somewhere">
<input type="text" name="something" id="something" />
</form>
I have no clue how to remove the div-element though, sorry.

torh wrote:
> Perhaps it adds the div due to compatibility with XHTML? I'm new here,> and quite new to Ruby on Rails too, but it seems fairly reasonable that> that's what RoR is doing.>> One must put a blocking object inside a form for it to be valid XHTML.>> Valid:> <form method="post" action="/somewhere">> <div>> <input type="text" name="something" id="something" />> </div>> </form>>> Invalid:> <form method="post" action="/somewhere">> <input type="text" name="something" id="something" />> </form>>>> I have no clue how to remove the div-element though, sorry.
Yes, it is one of my most hated Rails behaviours. It might be correct to
wrap input fields inside a block element, but consider this:
<form method="post" action="/somewhere">
<div><label for="something">Test</label>
<input type="text" name="something" id="something" />
</div>
</form>
which is correct xhtml, too. But Rails adds a second (unnecessary) div
around the input. It even hinders me in setting a custom class for this
div. I think that some of the tag logic needs to be reworked.