diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig index a7ce3e23fc96c..cd30f8bb8f89a 100644 --- a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig +++ b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig @@ -257,7 +257,8 @@ {{- label|trans(label_translation_parameters, translation_domain)|raw -}} {%- endif -%} {%- endif -%} - {% block form_label_errors %}{{- form_errors(form) -}}{% endblock form_label_errors %} + + {% block form_label_errors %}{{- form_errors(form) -}}{% endblock form_label_errors %} {%- else -%} {%- if errors|length > 0 -%}
@@ -315,8 +316,8 @@ {%- endif -%} {%- endif -%} {%- endif -%} - {{- form_errors(form) -}} + {{- form_errors(form) -}} {%- endif -%} {%- endblock checkbox_radio_label %} @@ -341,7 +342,7 @@ {% block form_errors -%} {%- if errors|length > 0 -%} - + {%- for error in errors -%} {{ 'Error'|trans({}, 'validators') }} {{ error.message }} diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4HorizontalLayoutTestCase.php b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4HorizontalLayoutTestCase.php index ce8a733665854..322eba126730b 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4HorizontalLayoutTestCase.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4HorizontalLayoutTestCase.php @@ -31,14 +31,12 @@ public function testRow() '/div [ ./label[@for="name"] - [ - ./span[@class="alert alert-danger d-block"] - [./span[@class="d-block"] - [./span[.="[trans]Error[/trans]"]] - [./span[.="[trans]Error![/trans]"]] - ] - [count(./span)=1] + /following-sibling::span[@class="alert alert-danger d-block mb-1"] + [./span[@class="d-block"] + [./span[.="[trans]Error[/trans]"]] + [./span[.="[trans]Error![/trans]"]] ] + [count(./span)=1] /following-sibling::div[./input[@id="name"]] ] ' diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4LayoutTestCase.php b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4LayoutTestCase.php index e329b5d49ec16..199bd60fc924a 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4LayoutTestCase.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4LayoutTestCase.php @@ -41,14 +41,12 @@ public function testRow() '/div [ ./label[@for="name"] - [ - ./span[@class="alert alert-danger d-block"] - [./span[@class="d-block"] - [./span[.="[trans]Error[/trans]"]] - [./span[.="[trans]Error![/trans]"]] - ] - [count(./span)=1] + /following-sibling::span[@class="alert alert-danger d-block mb-1"] + [./span[@class="d-block"] + [./span[.="[trans]Error[/trans]"]] + [./span[.="[trans]Error![/trans]"]] ] + [count(./span)=1] /following-sibling::input[@id="name"] ] ' @@ -324,7 +322,7 @@ public function testErrors() $this->assertMatchesXpath($html, '/span - [@class="alert alert-danger d-block"] + [@class="alert alert-danger d-block mb-1"] [ ./span[@class="d-block"] [./span[.="[trans]Error[/trans]"]] diff --git a/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php index cf98191233057..05f5cbd26b47a 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php @@ -60,10 +60,18 @@ public function testCompile() $this->registerTwigRuntimeLoader($environment, $formRenderer); $compiler = new Compiler($environment); + // There's a different result when testing in Symfony 4 with PHP 8.2 + high-deps + // This workaround is used to deal with the difference. + $source = '[1 => "tpl1", 0 => "tpl2"]'; + if ('["tpl1", "tpl2"]' === (new Compiler($environment))->subcompile($node->getNode('resources'))->getSource()) { + $source = '["tpl1", "tpl2"]'; + } + $this->assertEquals( sprintf( - '$this->env->getRuntime("Symfony\\\\Component\\\\Form\\\\FormRenderer")->setTheme(%s, [1 => "tpl1", 0 => "tpl2"], true);', - $this->getVariableGetter('form') + '$this->env->getRuntime("Symfony\\\\Component\\\\Form\\\\FormRenderer")->setTheme(%s, %s, true);', + $this->getVariableGetter('form'), + $source ), trim($compiler->compile($node)->getSource()) ); @@ -72,8 +80,9 @@ public function testCompile() $this->assertEquals( sprintf( - '$this->env->getRuntime("Symfony\\\\Component\\\\Form\\\\FormRenderer")->setTheme(%s, [1 => "tpl1", 0 => "tpl2"], false);', - $this->getVariableGetter('form') + '$this->env->getRuntime("Symfony\\\\Component\\\\Form\\\\FormRenderer")->setTheme(%s, %s, false);', + $this->getVariableGetter('form'), + $source ), trim($compiler->compile($node)->getSource()) );