Skip to content

Commit

Permalink
[Form] Do not render default ID attribute on empty form name
Browse files Browse the repository at this point in the history
Bug fix: no
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: -
Todo: -

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.
  • Loading branch information
canni committed Jan 18, 2012
1 parent f842739 commit 693d1ec
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
Expand Up @@ -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)); } ?>
4 changes: 1 addition & 3 deletions src/Symfony/Component/Form/Extension/Core/Type/FieldType.php
Expand Up @@ -86,9 +86,7 @@ public function buildView(FormView $view, FormInterface $form)
$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;
}

Expand Down

0 comments on commit 693d1ec

Please sign in to comment.