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 5dcaaad

Browse filesBrowse files
committed
Make sure form errors is valid HTML
1 parent 866a142 commit 5dcaaad
Copy full SHA for 5dcaaad

File tree

3 files changed

+28
-36
lines changed
Filter options

3 files changed

+28
-36
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
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -261,12 +261,12 @@
261261

262262
{% block form_errors -%}
263263
{%- if errors|length > 0 -%}
264-
<div class="{% if form is not rootform %}invalid-feedback d-block{% else %}alert alert-danger{% endif %}">
265-
<ul class="list-unstyled mb-0">
266-
{%- for error in errors -%}
267-
<li><span class="initialism form-error-icon badge badge-danger">{{ 'Error'|trans({}, 'validators') }}</span> <span class="form-error-message">{{ error.message }}</span></li>
268-
{%- endfor -%}
269-
</ul>
270-
</div>
264+
<span class="{% if form is not rootform %}invalid-feedback d-block{% else %}alert alert-danger{% endif %}">
265+
{%- for error in errors -%}
266+
<span class="mb-0 d-block">
267+
<span class="initialism form-error-icon badge badge-danger">{{ 'Error'|trans({}, 'validators') }}</span> <span class="form-error-message">{{ error.message }}</span>
268+
</span>
269+
{%- endfor -%}
270+
</span>
271271
{%- endif %}
272272
{%- endblock form_errors %}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/AbstractBootstrap4HorizontalLayoutTest.php
+6-8Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,12 @@ public function testRow()
3232
[
3333
./label[@for="name"]
3434
[
35-
./div[
36-
./ul
37-
[./li
38-
[./span[.="[trans]Error[/trans]"]]
39-
[./span[.="[trans]Error![/trans]"]]
40-
]
41-
[count(./li)=1]
42-
]
35+
./span[@class="alert alert-danger"]
36+
[./span[@class="mb-0 d-block"]
37+
[./span[.="[trans]Error[/trans]"]]
38+
[./span[.="[trans]Error![/trans]"]]
39+
]
40+
[count(./span)=1]
4341
]
4442
/following-sibling::div[./input[@id="name"]]
4543
]

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/AbstractBootstrap4LayoutTest.php
+15-21Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,12 @@ public function testRow()
3232
[
3333
./label[@for="name"]
3434
[
35-
./div[
36-
./ul
37-
[./li
38-
[./span[.="[trans]Error[/trans]"]]
39-
[./span[.="[trans]Error![/trans]"]]
40-
]
41-
[count(./li)=1]
42-
]
35+
./span[@class="alert alert-danger"]
36+
[./span[@class="mb-0 d-block"]
37+
[./span[.="[trans]Error[/trans]"]]
38+
[./span[.="[trans]Error![/trans]"]]
39+
]
40+
[count(./span)=1]
4341
]
4442
/following-sibling::input[@id="name"]
4543
]
@@ -162,22 +160,18 @@ public function testErrors()
162160
$html = $this->renderErrors($view);
163161

164162
$this->assertMatchesXpath($html,
165-
'/div
163+
'/span
166164
[@class="alert alert-danger"]
167165
[
168-
./ul
169-
[@class="list-unstyled mb-0"]
170-
[
171-
./li
172-
[./span[.="[trans]Error[/trans]"]]
173-
[./span[.="[trans]Error 1[/trans]"]]
174-
175-
/following-sibling::li
176-
[./span[.="[trans]Error[/trans]"]]
177-
[./span[.="[trans]Error 2[/trans]"]]
178-
]
179-
[count(./li)=2]
166+
./span[@class="mb-0 d-block"]
167+
[./span[.="[trans]Error[/trans]"]]
168+
[./span[.="[trans]Error 1[/trans]"]]
169+
170+
/following-sibling::span[@class="mb-0 d-block"]
171+
[./span[.="[trans]Error[/trans]"]]
172+
[./span[.="[trans]Error 2[/trans]"]]
180173
]
174+
[count(./span)=2]
181175
'
182176
);
183177
}

0 commit comments

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