Skip to content

Commit 2ae5058

Browse files
committed
bug #271 [LiveComponent] Skip clearing non clearable form errors (norkunas)
This PR was merged into the 2.x branch. Discussion ---------- [LiveComponent] Skip clearing non clearable form errors | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | Tickets | Fix #265 | License | MIT Commits ------- d64f662 [LiveComponent] Skip clearing non clearable form errors
2 parents 609f23b + d64f662 commit 2ae5058

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/LiveComponent/src/ComponentWithFormTrait.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\UX\LiveComponent;
1313

14-
use Symfony\Component\Form\Form;
14+
use Symfony\Component\Form\ClearableErrorsInterface;
1515
use Symfony\Component\Form\FormInterface;
1616
use Symfony\Component\Form\FormView;
1717
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
@@ -210,9 +210,9 @@ private function getFormInstance(): FormInterface
210210
return $this->formInstance;
211211
}
212212

213-
private function clearErrorsForNonValidatedFields(Form $form, string $currentPath = ''): void
213+
private function clearErrorsForNonValidatedFields(FormInterface $form, string $currentPath = ''): void
214214
{
215-
if (!$currentPath || !\in_array($currentPath, $this->validatedFields, true)) {
215+
if ($form instanceof ClearableErrorsInterface && (!$currentPath || !\in_array($currentPath, $this->validatedFields, true))) {
216216
$form->clearErrors();
217217
}
218218

0 commit comments

Comments
 (0)