Skip to content

Commit

Permalink
bug #28115 [Form] Remove extra .form-group wrapper around file widget…
Browse files Browse the repository at this point in the history
… 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 #27958 and #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
-------

01e7fe4 [Form] Remove extra .form-group wrapper around file widget in bootstrap 4
  • Loading branch information
nicolas-grekas committed Aug 7, 2018
2 parents d59e97f + 01e7fe4 commit 3e47827
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 31 deletions.
Expand Up @@ -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 -%}
Expand Down
Expand Up @@ -942,17 +942,13 @@ public function testFile()

$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"]
]
'
);
Expand All @@ -964,17 +960,13 @@ public function testFileWithPlaceholder()

$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]"]
]
'
);
Expand Down

0 comments on commit 3e47827

Please sign in to comment.