Skip to content

Commit 8157bc0

Browse files
ycerutofabpot
authored andcommitted
[WebProfilerBundle][Form][DX] To expand the form nodes that contains children with errors
1 parent 35ad679 commit 8157bc0

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

Resources/views/Collector/form.html.twig

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@
164164
font-weight: bold;
165165
vertical-align: middle;
166166
}
167+
.has-error {
168+
color: #B0413E;
169+
}
167170
.errors h3 {
168171
color: #B0413E;
169172
}
@@ -423,11 +426,12 @@
423426
</script>
424427
{% endblock %}
425428

426-
{% macro form_tree_entry(name, data, expanded) %}
429+
{% macro form_tree_entry(name, data, is_root) %}
427430
{% import _self as tree %}
431+
{% set has_error = data.errors is defined and data.errors|length > 0 %}
428432
<li>
429433
<div class="tree-inner" data-tab-target-id="{{ data.id }}-details">
430-
{% if data.errors is defined and data.errors|length > 0 %}
434+
{% if has_error %}
431435
<div class="badge-error">{{ data.errors|length }}</div>
432436
{% endif %}
433437

@@ -437,11 +441,13 @@
437441
<div class="toggle-icon empty"></div>
438442
{% endif %}
439443

440-
{{ name|default('(no name)') }} {% if data.type_class is defined %}[<abbr title="{{ data.type_class }}">{{ data.type_class|split('\\')|last }}</abbr>]{% endif %}
444+
<span {% if has_error or data.has_children_error|default(false) %}class="has-error"{% endif %}>
445+
{{ name|default('(no name)') }} {% if data.type_class is defined %}[<abbr title="{{ data.type_class }}">{{ data.type_class|split('\\')|last }}</abbr>]{% endif %}
446+
</span>
441447
</div>
442448

443449
{% if data.children is not empty %}
444-
<ul id="{{ data.id }}-children" {% if not expanded %}class="hidden"{% endif %}>
450+
<ul id="{{ data.id }}-children" {% if not is_root and not data.has_children_error|default(false) %}class="hidden"{% endif %}>
445451
{% for childName, childData in data.children %}
446452
{{ tree.form_tree_entry(childName, childData, false) }}
447453
{% endfor %}

0 commit comments

Comments
 (0)