You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 10, 2022. It is now read-only.
I have an error at an index of a collection of fields but the method is not keeping the index. See attachment. The fields in red are in error but only the lines 2 and 3 should be red. My validation is column 2 value of current row should be greater than or equals to column 3 of previous row.
In the following example : on the row with 2%, 200 should be greater than or equals to 300 of the row with 1%. Same apply on next row : 250 should be greater than or equals to 300 of the row with 2%.
Is there a way to set the index properly ? Here is my validation callback, applied on the array:
newCallback([
// $steps catains my collection with ['percentage' => 1, 'min' => 100, 'max' => 300] as first item.'callback' => function (array$steps, ExecutionContextInterface$context) {
if (($count = \count($steps)) <= 1) {
return;
}
$parentStep = $steps[0];
$index = 1;
while ($index < $count) {
if ($parentStep['max'] > $steps[$index]['min']) {
$context
->buildViolation('La fourchette minimale est inférieure à la fourchette maximale de la ligne précédente.')
->atPath($index)
->addViolation();
}
$parentStep = $steps[$index];
++$index;
}
},
])
But the flattened errors are always starting at index 0 but should instead keep the given index. How can it be fixed?
Thank you
The text was updated successfully, but these errors were encountered:
Found an alternative to attach the violation atPath(sprintf('[%d][min]', $index)) which also can sound more logical as the error is on this field. But Still, would it be possible to attach the error at index level?
Thank you
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi,
I borrowed your code from
ViolationFormException::getFlatternErrors
for my project as I don't need extra stuff your bundle is doing.I have an error at an index of a collection of fields but the method is not keeping the index. See attachment. The fields in red are in error but only the lines 2 and 3 should be red. My validation is column 2 value of current row should be greater than or equals to column 3 of previous row.
In the following example : on the row with 2%, 200 should be greater than or equals to 300 of the row with 1%. Same apply on next row : 250 should be greater than or equals to 300 of the row with 2%.
Is there a way to set the index properly ? Here is my validation callback, applied on the array:
But the flattened errors are always starting at index
0
but should instead keep the given index. How can it be fixed?Thank you
The text was updated successfully, but these errors were encountered: