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 babe8ce

Browse filesBrowse files
committed
properly cascade validation to child forms
1 parent 3519647 commit babe8ce
Copy full SHA for babe8ce

File tree

1 file changed

+2
-5
lines changed
Filter options

1 file changed

+2
-5
lines changed

‎src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php
+2-5Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ public function validate($form, Constraint $formConstraint)
7272
if ($groups instanceof GroupSequence) {
7373
// Validate the data, the form AND nested fields in sequence
7474
$violationsCount = $this->context->getViolations()->count();
75-
$fieldPropertyPath = \is_object($data) ? 'children[%s]' : 'children%s';
7675

7776
foreach ($groups->groups as $group) {
7877
if ($validateDataGraph) {
@@ -91,7 +90,7 @@ public function validate($form, Constraint $formConstraint)
9190
// in different steps without breaking early enough
9291
$this->resolvedGroups[$field] = (array) $group;
9392
$fieldFormConstraint = new Form();
94-
$validator->atPath(sprintf($fieldPropertyPath, $field->getPropertyPath()))->validate($field, $fieldFormConstraint);
93+
$validator->atPath(sprintf('children[%s]', $field->getName()))->validate($field, $fieldFormConstraint);
9594
}
9695
}
9796

@@ -100,8 +99,6 @@ public function validate($form, Constraint $formConstraint)
10099
}
101100
}
102101
} else {
103-
$fieldPropertyPath = \is_object($data) ? 'children[%s]' : 'children%s';
104-
105102
if ($validateDataGraph) {
106103
$validator->atPath('data')->validate($data, null, $groups);
107104
}
@@ -132,7 +129,7 @@ public function validate($form, Constraint $formConstraint)
132129
if ($field->isSubmitted()) {
133130
$this->resolvedGroups[$field] = $groups;
134131
$fieldFormConstraint = new Form();
135-
$validator->atPath(sprintf($fieldPropertyPath, $field->getPropertyPath()))->validate($field, $fieldFormConstraint);
132+
$validator->atPath(sprintf('children[%s]', $field->getName()))->validate($field, $fieldFormConstraint);
136133
}
137134
}
138135
}

0 commit comments

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