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

[WebProfilerBundle][Form][DX] To expand the form nodes that contains children with errors #19339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
highlighting full error path
  • Loading branch information
yceruto committed Jul 26, 2016
commit a85adae9c0874cd9624218f02511d82e6ae5d55b
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@
font-weight: bold;
vertical-align: middle;
}
.has-error {
color: #B0413E;
}
.errors h3 {
color: #B0413E;
}
Expand Down Expand Up @@ -423,11 +426,12 @@
</script>
{% endblock %}

{% macro form_tree_entry(name, data, expanded) %}
{% macro form_tree_entry(name, data, is_root) %}
{% import _self as tree %}
{% set has_error = data.errors is defined and data.errors|length > 0 %}
<li>
<div class="tree-inner" data-tab-target-id="{{ data.id }}-details">
{% if data.errors is defined and data.errors|length > 0 %}
{% if has_error %}
<div class="badge-error">{{ data.errors|length }}</div>
{% endif %}

Expand All @@ -437,13 +441,15 @@
<div class="toggle-icon empty"></div>
{% endif %}

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

{% if data.children is not empty %}
<ul id="{{ data.id }}-children" {% if not expanded %}class="hidden"{% endif %}>
<ul id="{{ data.id }}-children" {% if not is_root and not data.has_children_error|default(false) %}class="hidden"{% endif %}>
{% for childName, childData in data.children %}
{{ tree.form_tree_entry(childName, childData, childData.expanded|default(false)) }}
{{ tree.form_tree_entry(childName, childData, false) }}
{% endfor %}
</ul>
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,10 @@ public function collectSubmittedData(FormInterface $form)
foreach ($form as $child) {
$this->collectSubmittedData($child);

// Expand current form if there are children expanded or with errors
if (empty($this->dataByForm[$hash]['expanded'])) {
// Expand current form if there are children with errors
if (empty($this->dataByForm[$hash]['has_children_error'])) {
$childData = $this->dataByForm[spl_object_hash($child)];
$this->dataByForm[$hash]['expanded'] = !empty($childData['expanded']) || !empty($childData['errors']);
$this->dataByForm[$hash]['has_children_error'] = !empty($childData['has_children_error']) || !empty($childData['errors']);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function testBuildPreliminaryFormTree()
'config' => 'foo',
'default_data' => 'foo',
'submitted_data' => 'foo',
'expanded' => false,
'has_children_error' => false,
'children' => array(
'child' => $childFormData,
),
Expand Down Expand Up @@ -324,7 +324,7 @@ public function testBuildFinalFormTree()
'config' => 'foo',
'default_data' => 'foo',
'submitted_data' => 'foo',
'expanded' => false,
'has_children_error' => false,
'children' => array(
'child' => $childFormData,
),
Expand Down Expand Up @@ -579,11 +579,11 @@ public function testCollectSubmittedDataExpandedFormsErrors()
$child2Data = $formData['children']['child2'];
$child21Data = $child2Data['children']['child21'];

$this->assertTrue($formData['expanded']);
$this->assertTrue($child1Data['expanded']);
$this->assertFalse(isset($child11Data['expanded']), 'The leaf data does not contains "expanded" property.');
$this->assertFalse($child2Data['expanded']);
$this->assertFalse(isset($child21Data['expanded']), 'The leaf data does not contains "expanded" property.');
$this->assertTrue($formData['has_children_error']);
$this->assertTrue($child1Data['has_children_error']);
$this->assertFalse(isset($child11Data['has_children_error']), 'The leaf data does not contains "has_children_error" property.');
$this->assertFalse($child2Data['has_children_error']);
$this->assertFalse(isset($child21Data['has_children_error']), 'The leaf data does not contains "has_children_error" property.');
}

private function createForm($name)
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.