From 5dcaaadb5e8c01148b67d009c95a5118849f9a55 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Sun, 18 Mar 2018 15:29:46 +0100 Subject: [PATCH] Make sure form errors is valid HTML --- .../views/Form/bootstrap_4_layout.html.twig | 14 ++++---- ...AbstractBootstrap4HorizontalLayoutTest.php | 14 ++++---- .../Tests/AbstractBootstrap4LayoutTest.php | 36 ++++++++----------- 3 files changed, 28 insertions(+), 36 deletions(-) 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 a3484d9036bec..6b5183592eded 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 @@ -261,12 +261,12 @@ {% block form_errors -%} {%- if errors|length > 0 -%} -
- -
+ + {%- for error in errors -%} + + {{ 'Error'|trans({}, 'validators') }} {{ error.message }} + + {%- endfor -%} + {%- endif %} {%- endblock form_errors %} diff --git a/src/Symfony/Component/Form/Tests/AbstractBootstrap4HorizontalLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractBootstrap4HorizontalLayoutTest.php index e8ede167b3802..c906c6549ad2f 100644 --- a/src/Symfony/Component/Form/Tests/AbstractBootstrap4HorizontalLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractBootstrap4HorizontalLayoutTest.php @@ -32,14 +32,12 @@ public function testRow() [ ./label[@for="name"] [ - ./div[ - ./ul - [./li - [./span[.="[trans]Error[/trans]"]] - [./span[.="[trans]Error![/trans]"]] - ] - [count(./li)=1] - ] + ./span[@class="alert alert-danger"] + [./span[@class="mb-0 d-block"] + [./span[.="[trans]Error[/trans]"]] + [./span[.="[trans]Error![/trans]"]] + ] + [count(./span)=1] ] /following-sibling::div[./input[@id="name"]] ] diff --git a/src/Symfony/Component/Form/Tests/AbstractBootstrap4LayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractBootstrap4LayoutTest.php index ec97577818d4d..aa0600e58fa3e 100644 --- a/src/Symfony/Component/Form/Tests/AbstractBootstrap4LayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractBootstrap4LayoutTest.php @@ -32,14 +32,12 @@ public function testRow() [ ./label[@for="name"] [ - ./div[ - ./ul - [./li - [./span[.="[trans]Error[/trans]"]] - [./span[.="[trans]Error![/trans]"]] - ] - [count(./li)=1] - ] + ./span[@class="alert alert-danger"] + [./span[@class="mb-0 d-block"] + [./span[.="[trans]Error[/trans]"]] + [./span[.="[trans]Error![/trans]"]] + ] + [count(./span)=1] ] /following-sibling::input[@id="name"] ] @@ -162,22 +160,18 @@ public function testErrors() $html = $this->renderErrors($view); $this->assertMatchesXpath($html, -'/div +'/span [@class="alert alert-danger"] [ - ./ul - [@class="list-unstyled mb-0"] - [ - ./li - [./span[.="[trans]Error[/trans]"]] - [./span[.="[trans]Error 1[/trans]"]] - - /following-sibling::li - [./span[.="[trans]Error[/trans]"]] - [./span[.="[trans]Error 2[/trans]"]] - ] - [count(./li)=2] + ./span[@class="mb-0 d-block"] + [./span[.="[trans]Error[/trans]"]] + [./span[.="[trans]Error 1[/trans]"]] + + /following-sibling::span[@class="mb-0 d-block"] + [./span[.="[trans]Error[/trans]"]] + [./span[.="[trans]Error 2[/trans]"]] ] + [count(./span)=2] ' ); } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy