bug #28115 [Form] Remove extra .form-group wrapper around file widget in bootstrap 4 (MrMitch)

This PR was merged into the 4.1 branch.

Discussion
----------

[Form] Remove extra .form-group wrapper around file widget in bootstrap 4

| Q             | A
| ------------- | ---
| Branch?       | 4.1
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        |  n/a

This is a follow-up to https://github.com/symfony/symfony/pull/27958 and https://github.com/symfony/symfony/pull/27919 by @apfelbox .

It fixes an extra space between the help text of a FileType widget and the widget itself. The extra space was caused by a `.form-group` wrapper in the `file_widget` block.

Commits
-------

01e7fe4fb0 [Form] Remove extra .form-group wrapper around file widget in bootstrap 4
This commit is contained in:
Nicolas Grekas 2018-08-07 10:53:53 +02:00
commit 3e47827c98
2 changed files with 21 additions and 31 deletions

View File

@ -115,17 +115,15 @@
{%- endblock percent_widget %}
{% block file_widget -%}
<div class="form-group">
<{{ element|default('div') }} class="custom-file">
{%- set type = type|default('file') -%}
{{- block('form_widget_simple') -}}
<label for="{{ form.vars.id }}" class="custom-file-label">
{%- if attr.placeholder is defined -%}
{{- translation_domain is same as(false) ? attr.placeholder : attr.placeholder|trans({}, translation_domain) -}}
{%- endif -%}
</label>
</{{ element|default('div') }}>
</div>
<{{ element|default('div') }} class="custom-file">
{%- set type = type|default('file') -%}
{{- block('form_widget_simple') -}}
<label for="{{ form.vars.id }}" class="custom-file-label">
{%- if attr.placeholder is defined -%}
{{- translation_domain is same as(false) ? attr.placeholder : attr.placeholder|trans({}, translation_domain) -}}
{%- endif -%}
</label>
</{{ element|default('div') }}>
{% endblock %}
{% block form_widget_simple -%}

View File

@ -942,17 +942,13 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
$this->assertWidgetMatchesXpath($form->createView(), array('id' => 'n/a', 'attr' => array('class' => 'my&class form-control-file')),
'/div
[@class="form-group"]
[@class="custom-file"]
[
./div
[@class="custom-file"]
[
./input
[@type="file"]
[@name="name"]
/following-sibling::label
[@for="name"]
]
./input
[@type="file"]
[@name="name"]
/following-sibling::label
[@for="name"]
]
'
);
@ -964,17 +960,13 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
$this->assertWidgetMatchesXpath($form->createView(), array('id' => 'n/a', 'attr' => array('class' => 'my&class form-control-file', 'placeholder' => 'Custom Placeholder')),
'/div
[@class="form-group"]
[@class="custom-file"]
[
./div
[@class="custom-file"]
[
./input
[@type="file"]
[@name="name"]
/following-sibling::label
[@for="name" and text() = "[trans]Custom Placeholder[/trans]"]
]
./input
[@type="file"]
[@name="name"]
/following-sibling::label
[@for="name" and text() = "[trans]Custom Placeholder[/trans]"]
]
'
);