<form> tag is self-closing before input fields .. (HAML generator used)

81 views
Skip to first unread message

Erwin

unread,
Oct 16, 2012, 1:43:50 PM10/16/12
to Ruby on Rails: Talk
The form is inside a table, enclosing a <tr>

= form_tag admins_backoffice_dashboards_path, :remote =>"true" do
%tr.search
%th= link_to t(:clear), "#", :id => :clearFilter
%th= select_tag :role,
options_from_collection_for_select(Role.global, :id, :name, :selected
=> @role_id )
%th= text_field_tag :email, nil, :value => @email
%th= submit_tag t(:search).capitalize

the generated html code is :

<table class="table table-condensed">
<form method="post" data-remote="true" action="/en/backoffice/
dashboards/admins" accept-charset="UTF-8"></form>
<tr class="search">
<th><a id="clearFilter" href="#">Clear</a></th>
<th>
<select name="role" id="role" class="input-medium list">
</option><option value="2">superadmin</option>
<option value="3">manager</option>
<option value="4">employee</option>
</select>
</th>
<th><input type="text" name="email" id="email"></
th>
<th><input type="submit" value="Search"
name="commit"></th>
</tr>
</table>

what could be wrong ..? is it so obvious ? thanks for feedback


Hassan Schroeder

unread,
Oct 16, 2012, 1:53:40 PM10/16/12
to rubyonra...@googlegroups.com
On Tue, Oct 16, 2012 at 10:43 AM, Erwin <yves_...@mac.com> wrote:
> The form is inside a table, enclosing a <tr>

That's not legal markup. Either wrap the form around the entire table
or put it completely inside a cell.

--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
http://about.me/hassanschroeder
twitter: @hassan

Erwin

unread,
Oct 16, 2012, 6:15:47 PM10/16/12
to Ruby on Rails: Talk
Thanks , I had that feeling... I'll test it by tomorrow ... is there
any links related to this being illegal ? just for my notetaker
pad ...

On 16 oct, 19:55, Hassan Schroeder <hassan.schroe...@gmail.com> wrote:
> On Tue, Oct 16, 2012 at 10:43 AM, Erwin <yves_duf...@mac.com> wrote:
> > The form is inside a table, enclosing a <tr>
>
> That's not legal markup. Either wrap the form around the entire table
> or put it completely inside a cell.
>
> --
> Hassan Schroeder ------------------------ hassan.schroe...@gmail.comhttp://about.me/hassanschroeder
> twitter: @hassan

Hassan Schroeder

unread,
Oct 16, 2012, 7:58:49 PM10/16/12
to rubyonra...@googlegroups.com
On Tue, Oct 16, 2012 at 3:15 PM, Erwin <yves_...@mac.com> wrote:
> Thanks , I had that feeling... I'll test it by tomorrow ... is there
> any links related to this being illegal ? just for my notetaker
> pad ...

The HTML 4.01 DTDs are what I usually refer to when in doubt:

<http://www.w3.org/TR/REC-html40/sgml/dtd.html>

I'm under the impression HTML 5 doesn't use DTDs but I'm trying
to leave markup to others as much as possible these days :-)

HTH!

Colin Law

unread,
Oct 17, 2012, 3:37:11 AM10/17/12
to rubyonra...@googlegroups.com
On 16 October 2012 23:15, Erwin <yves_...@mac.com> wrote:
> Thanks , I had that feeling... I'll test it by tomorrow ... is there
> any links related to this being illegal ? just for my notetaker
> pad ...

If ever you have any markup and you just want to check whether it is
legal you can paste it into the w3c html validator and it will check
it for you. In fact any time a page is misbehaving in a strange way
it is a good idea to check the html for validity, and before any page
is made public it should be checked. Even if a page looks ok there
may still be invalid html there which can make it perform differently
on different browsers.

Colin

>
> On 16 oct, 19:55, Hassan Schroeder <hassan.schroe...@gmail.com> wrote:
>> On Tue, Oct 16, 2012 at 10:43 AM, Erwin <yves_duf...@mac.com> wrote:
>> > The form is inside a table, enclosing a <tr>
>>
>> That's not legal markup. Either wrap the form around the entire table
>> or put it completely inside a cell.
>>
>> --
>> Hassan Schroeder ------------------------ hassan.schroe...@gmail.comhttp://about.me/hassanschroeder
>> twitter: @hassan
>
> --
> 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 rubyonra...@googlegroups.com.
> To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Jordon Bedwell

unread,
Oct 17, 2012, 4:13:08 AM10/17/12
to rubyonra...@googlegroups.com
On Wed, Oct 17, 2012 at 2:37 AM, Colin Law <cla...@googlemail.com> wrote:
> On 16 October 2012 23:15, Erwin <yves_...@mac.com> wrote:
>> Thanks , I had that feeling... I'll test it by tomorrow ... is there
>> any links related to this being illegal ? just for my notetaker
>> pad ...
>
> If ever you have any markup and you just want to check whether it is
> legal you can paste it into the w3c html validator and it will check
> it for you. In fact any time a page is misbehaving in a strange way
> it is a good idea to check the html for validity, and before any page
> is made public it should be checked. Even if a page looks ok there
> may still be invalid html there which can make it perform differently
> on different browsers.

Since I didn't see the rest of this I'll just comment as if it's
future-proofed markup. In HTML5 <form /> simply means <form>, it's a
grey area, it's not allowed but it's parsed and even has parsing rules
but it means <form> so you will end up with a parsing error eventually
possibly. It has parsing rules because of XML and XHTML. It does not
mean <form></form> like most people assume.

While I agree with Colin that you should check with the W3 validator I
also think that you should take any of the HTML5 markup validations
with a grain of salt and refer to the spec
http://dev.w3.org/html5/spec/ because there are grey areas that will
get you later.

Colin Law

unread,
Oct 17, 2012, 4:34:37 AM10/17/12
to rubyonra...@googlegroups.com
On 17 October 2012 09:13, Jordon Bedwell <envy...@gmail.com> wrote:
> On Wed, Oct 17, 2012 at 2:37 AM, Colin Law <cla...@googlemail.com> wrote:
>> On 16 October 2012 23:15, Erwin <yves_...@mac.com> wrote:
>>> Thanks , I had that feeling... I'll test it by tomorrow ... is there
>>> any links related to this being illegal ? just for my notetaker
>>> pad ...
>>
>> If ever you have any markup and you just want to check whether it is
>> legal you can paste it into the w3c html validator and it will check
>> it for you. In fact any time a page is misbehaving in a strange way
>> it is a good idea to check the html for validity, and before any page
>> is made public it should be checked. Even if a page looks ok there
>> may still be invalid html there which can make it perform differently
>> on different browsers.
>
> Since I didn't see the rest of this I'll just comment as if it's
> future-proofed markup. In HTML5 <form /> simply means <form>, it's a
> grey area, it's not allowed but it's parsed and even has parsing rules
> but it means <form> so you will end up with a parsing error eventually
> possibly. It has parsing rules because of XML and XHTML. It does not
> mean <form></form> like most people assume.

I don't understand what you mean by "it's not allowed". If it parses
without an error then how can it not be allowed? Or are you pointing
out that the spec is inconsistent?

Why would one want to do <form /> anyway?

Colin

>
> While I agree with Colin that you should check with the W3 validator I
> also think that you should take any of the HTML5 markup validations
> with a grain of salt and refer to the spec
> http://dev.w3.org/html5/spec/ because there are grey areas that will
> get you later.
>

Frederick Cheung

unread,
Oct 17, 2012, 4:44:21 AM10/17/12
to rubyonra...@googlegroups.com


On Tuesday, October 16, 2012 6:55:04 PM UTC+1, Hassan Schroeder wrote:
On Tue, Oct 16, 2012 at 10:43 AM, Erwin <yves_...@mac.com> wrote:
> The form is inside a table, enclosing a <tr>

That's not legal markup. Either wrap the form around the entire table
or put it completely inside a cell.


Although haml doesn't know that - it will quite happily generate markup that is invalid in that way. My money would be the the tr is indented with something that looks like a space to a human, but not to haml (maybe a tab or one of the funky unicode spacing characters)

Fred

Jordon Bedwell

unread,
Oct 17, 2012, 4:44:51 AM10/17/12
to rubyonra...@googlegroups.com
On Wed, Oct 17, 2012 at 3:34 AM, Colin Law <cla...@googlemail.com> wrote:
> I don't understand what you mean by "it's not allowed". If it parses
> without an error then how can it not be allowed? Or are you pointing
> out that the spec is inconsistent?
>
> Why would one want to do <form /> anyway?

That's exactly what I mean by a grey area, it's one of those things
that you're not supposed to do, it's "not allowed" but they allow it
to parse and pass because it's so popular and because it was so widely
used prior to HTML5 via XHTML from XML, that and it's converted to
<tag> which is perfectly valid in some circumstance. I don't quite
remember if there was intent to make it fully illegal but right now
it's a grey area in that it parses but you are not supposed to do it
because it's "not allowed" in HTML5.

TL;DR

<form /> -> <form> = valid but could lead to parse error because of
nesting issues.
<form /> is not legal in HTML5 but parsed and "passed" because of
syntactic sugar and XML.
Reply all
Reply to author
Forward
0 new messages