This project is archived and is in readonly mode.
Make obvious and integrate HTML5 "required" attribute
Reported by Adrian Perez | October 14th, 2010 @ 05:47 PM
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
Comments and changes to this ticket
-
José Valim October 14th, 2010 @ 06:15 PM
- 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.
-
Adrian Perez October 14th, 2010 @ 06:19 PM
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.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>