Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Make obvious and integrate HTML5 "required" attribute

#5810

The HTML5 "required" attribute, as it's name implies, tells the aware-browsers, that they shouldn't submit the form is a field marked with this attribute isn't filled in. Currently, I can achieve the behaviour using rails, by passing a

  :required => true

to any helper which actually generates:

 ... required="required"

markup.

The HTML5 specs tell you that the value of the attribute doesn't matter, but I still believe is more concise to make it generate markup like this:

  <input type="text" name="sample" required />

The same for the other attributes such as autofocus, disabled, and the like.

I mean to be able to do something like this:

def test_required_text_field_tag
    expected = %{<input name="name" id="name" type="text" required />}
    assert_dom_equal(expected, text_field_tag(:name, :required => true)
end

Reported by Adrian Perez · October 14th, 2010 @ 05:47 PM

State: wontfix
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. José Valim
    José Valim
    • State changed from new to wontfix
    • Importance changed from to Low

    Unfortunately, changing this will break support to previous rails versions, as the part which generates required="required" is a common path to all html options. And IMHO it makes no sense to whitelist a few HTML5 attributes for cosmetic reasons.

    October 14th, 2010 @ 06:15 PM

  2. Adrian Perez
    Adrian Perez

    Good enough for me, but still it does seem odd, and we don't know whereelse this could be happing so we're going to have: required="required", disabled="disabled", autofocus="autofocus". Quite odd. But still HTML5 is fairly new.

    October 14th, 2010 @ 06:19 PM