Skip to content

Commit fce6166

Browse files
committed
feature #19339 [WebProfilerBundle][Form][DX] To expand the form nodes that contains children with errors (yceruto)
This PR was squashed before being merged into the 3.2-dev branch (closes #19339). Discussion ---------- [WebProfilerBundle][Form][DX] To expand the form nodes that contains children with errors | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Currently when we use nested forms and an error occurs into one of them, it's not displayed "easily" in the form panel profiler: ![first](https://cloud.githubusercontent.com/assets/2028198/17125622/1fd15142-52c3-11e6-830e-17b3e341ba60.png) This happen because only the root form is expanded and the children are shown collapsed "by default". **The main problem is to search where is the form with error**. The purpose of this PR is to show expanded all forms that contains children with error, reducing a little bit the developer's time when debugging. PR result when we access to the form panel profiler: ![form-error-result](https://cloud.githubusercontent.com/assets/2028198/17125447/83eb9c0c-52c1-11e6-94bc-a2a7492eea43.png) In red the full path to the error. ![form-error-result2](https://cloud.githubusercontent.com/assets/2028198/17125459/a04de95e-52c1-11e6-8980-84a5dcd0914a.png) Commits ------- d626b28 [WebProfilerBundle][Form][DX] To expand the form nodes that contains children with errors
2 parents 85afded + 8157bc0 commit fce6166

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)