Skip to content

Commit

Permalink
[Form] Rewrite boolean attributes to match HTML spec
Browse files Browse the repository at this point in the history
'The presence of a boolean attribute on an element represents the true value, and the absence of the attribute represents the false value.'

- http://www.w3.org/html/wg/drafts/html/master/infrastructure.html#boolean-attribute
  • Loading branch information
leevigraham authored and webmozart committed Sep 30, 2013
1 parent e24dbf7 commit 8e4c2a7
Showing 1 changed file with 29 additions and 3 deletions.
Expand Up @@ -373,15 +373,41 @@

{% block widget_attributes %}
{% spaceless %}
id="{{ id }}" name="{{ full_name }}"{% if read_only %} readonly="readonly"{% endif %}{% if disabled %} disabled="disabled"{% endif %}{% if required %} required="required"{% endif %}{% if max_length %} maxlength="{{ max_length }}"{% endif %}{% if pattern %} pattern="{{ pattern }}"{% endif %}
{% for attrname, attrvalue in attr %}{% if attrname in ['placeholder', 'title'] %}{{ attrname }}="{{ attrvalue|trans({}, translation_domain) }}" {% else %}{{ attrname }}="{{ attrvalue }}" {% endif %}{% endfor %}
id="{{ id }}"
name="{{ full_name }}"
{% if read_only %} readonly="readonly"{% endif %}
{% if disabled %} disabled="disabled"{% endif %}
{% if required %} required="required"{% endif %}
{% if max_length %} maxlength="{{ max_length }}"{% endif %}
{% if pattern %} pattern="{{ pattern }}"{% endif %}
{% for attrname, attrvalue in attr %}
{% if attrname in ['placeholder', 'title'] %}
{{ attrname }}="{{ attrvalue|trans({}, translation_domain) }}"
{% else %}
{% if attrvalue is sameas(true) %}
{{ attrname }}="{{ attrname }}"
{% elseif attrvalue is not sameas(false) %}
{{ attrname }}="{{ attrvalue }}"
{% endif %}
{% endif %}
{% endfor %}
{% endspaceless %}
{% endblock widget_attributes %}

{% block widget_container_attributes %}
{% spaceless %}
{% if id is not empty %}id="{{ id }}" {% endif %}
{% for attrname, attrvalue in attr %}{{ attrname }}="{{ attrvalue }}" {% endfor %}
{% for attrname, attrvalue in attr %}
{% if attrname in ['placeholder', 'title'] %}
{{ attrname }}="{{ attrvalue|trans({}, translation_domain) }}"
{% else %}
{% if attrvalue is sameas(true) %}
{{ attrname }}="{{ attrname }}"
{% elseif attrvalue is not sameas(false) %}
{{ attrname }}="{{ attrvalue }}"
{% endif %}
{% endif %}
{% endfor %}
{% endspaceless %}
{% endblock widget_container_attributes %}

Expand Down

0 comments on commit 8e4c2a7

Please sign in to comment.