merged branch canni/avoid_rendering_id (PR #3145)
Commits
-------
693d1ec
[Form] Do not render default ID attribute on empty form name
Discussion
----------
[Form] Do not render default ID attribute on empty form name
Bug fix: no
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: -
Todo: -
[![Build Status](https://secure.travis-ci.org/canni/symfony.png)](http://travis-ci.org/canni/symfony)
This is cleanup after enabling empty form names, now form with empty name
will not render the default `id="form"` container attribute.
Developers can extend/override this behaviour by standard form theming methods.
See discussion [here](https://github.com/symfony/symfony/pull/2936/files)
This commit is contained in:
commit
ccdeccbce2
@ -287,7 +287,7 @@
|
||||
|
||||
{% block widget_container_attributes %}
|
||||
{% spaceless %}
|
||||
id="{{ id }}"
|
||||
{% if id is not empty %}id="{{ id }}" {% endif %}
|
||||
{% for attrname,attrvalue in attr %}{{attrname}}="{{attrvalue}}" {% endfor %}
|
||||
{% endspaceless %}
|
||||
{% endblock widget_container_attributes %}
|
||||
|
@ -1,2 +1,2 @@
|
||||
id="<?php echo $view->escape($id) ?>"
|
||||
<?php if (!empty($id)): ?>id="<?php echo $view->escape($id) ?>" <?php endif; ?>
|
||||
<?php foreach($attr as $k => $v) { printf('%s="%s" ', $view->escape($k), $view->escape($v)); } ?>
|
||||
|
@ -86,9 +86,7 @@ class FieldType extends AbstractType
|
||||
$fullName = $name;
|
||||
}
|
||||
} else {
|
||||
// If this form node have empty name, set id to `form`
|
||||
// to avoid rendering `id=""` in html structure
|
||||
$id = $name ?: 'form';
|
||||
$id = $name;
|
||||
$fullName = $name;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user