Skip to content

Commit 8e4c2a7

Browse files
leevigrahamwebmozart
authored andcommitted
[Form] Rewrite boolean attributes to match HTML spec
'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
1 parent e24dbf7 commit 8e4c2a7

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,15 +373,41 @@
373373

374374
{% block widget_attributes %}
375375
{% spaceless %}
376-
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 %}
377-
{% for attrname, attrvalue in attr %}{% if attrname in ['placeholder', 'title'] %}{{ attrname }}="{{ attrvalue|trans({}, translation_domain) }}" {% else %}{{ attrname }}="{{ attrvalue }}" {% endif %}{% endfor %}
376+
id="{{ id }}"
377+
name="{{ full_name }}"
378+
{% if read_only %} readonly="readonly"{% endif %}
379+
{% if disabled %} disabled="disabled"{% endif %}
380+
{% if required %} required="required"{% endif %}
381+
{% if max_length %} maxlength="{{ max_length }}"{% endif %}
382+
{% if pattern %} pattern="{{ pattern }}"{% endif %}
383+
{% for attrname, attrvalue in attr %}
384+
{% if attrname in ['placeholder', 'title'] %}
385+
{{ attrname }}="{{ attrvalue|trans({}, translation_domain) }}"
386+
{% else %}
387+
{% if attrvalue is sameas(true) %}
388+
{{ attrname }}="{{ attrname }}"
389+
{% elseif attrvalue is not sameas(false) %}
390+
{{ attrname }}="{{ attrvalue }}"
391+
{% endif %}
392+
{% endif %}
393+
{% endfor %}
378394
{% endspaceless %}
379395
{% endblock widget_attributes %}
380396

381397
{% block widget_container_attributes %}
382398
{% spaceless %}
383399
{% if id is not empty %}id="{{ id }}" {% endif %}
384-
{% for attrname, attrvalue in attr %}{{ attrname }}="{{ attrvalue }}" {% endfor %}
400+
{% for attrname, attrvalue in attr %}
401+
{% if attrname in ['placeholder', 'title'] %}
402+
{{ attrname }}="{{ attrvalue|trans({}, translation_domain) }}"
403+
{% else %}
404+
{% if attrvalue is sameas(true) %}
405+
{{ attrname }}="{{ attrname }}"
406+
{% elseif attrvalue is not sameas(false) %}
407+
{{ attrname }}="{{ attrvalue }}"
408+
{% endif %}
409+
{% endif %}
410+
{% endfor %}
385411
{% endspaceless %}
386412
{% endblock widget_container_attributes %}
387413

0 commit comments

Comments
 (0)