Skip to content

Commit d64f662

Browse files
committed
[LiveComponent] Skip clearing non clearable form errors
1 parent 609f23b commit d64f662

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)