Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c59bbc5

Browse filesBrowse files
committed
bug #26591 [TwigBridge] Make sure we always render errors. Eventhough labels are disabled (Nyholm)
This PR was merged into the 3.4 branch. Discussion ---------- [TwigBridge] Make sure we always render errors. Eventhough labels are disabled | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #26536 | License | MIT | Doc PR | If one use form type with `'label'=>false` then no errors where visible. This PR make sure we always print errors. Commits ------- d8f3de9 Make sure we always render errors. Eventhough labels are disabled
2 parents 866a142 + d8f3de9 commit c59bbc5
Copy full SHA for c59bbc5

File tree

2 files changed

+16
-0
lines changed
Filter options

2 files changed

+16
-0
lines changed

‎src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,12 @@
204204
{%- endif -%}
205205
{%- endif -%}
206206
<{{ element|default('label') }}{% if label_attr %}{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}{% endif %}>{{ translation_domain is same as(false) ? label : label|trans({}, translation_domain) }}{{- form_errors(form) -}}</{{ element|default('label') }}>
207+
{%- else -%}
208+
{%- if errors|length > 0 -%}
209+
<div id="{{ id }}_errors" class="mb-2">
210+
{{- form_errors(form) -}}
211+
</div>
212+
{%- endif -%}
207213
{%- endif -%}
208214
{%- endblock form_label %}
209215

‎src/Symfony/Component/Form/Tests/AbstractBootstrap4LayoutTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/AbstractBootstrap4LayoutTest.php
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,16 @@ public function testErrors()
182182
);
183183
}
184184

185+
public function testErrorWithNoLabel()
186+
{
187+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', array('label'=>false));
188+
$form->addError(new FormError('[trans]Error 1[/trans]'));
189+
$view = $form->createView();
190+
$html = $this->renderLabel($view);
191+
192+
$this->assertMatchesXpath($html, '//span[.="[trans]Error[/trans]"]');
193+
}
194+
185195
public function testCheckedCheckbox()
186196
{
187197
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType', true);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.