FormErrorIterator example

if ($flatten) {
                    foreach ($iterator as $error) {
                        $errors[] = $error;
                    }
                } else {
                    $errors[] = $iterator;
                }
            }
        }

        return new FormErrorIterator($this$errors);
    }

    public function clearErrors(bool $deep = false)static
    {
        $this->errors = [];

        if ($deep) {
            // Clear errors from children             foreach ($this as $child) {
                if ($child instanceof ClearableErrorsInterface) {
                    $child->clearErrors(true);
                }
private FormInterface $form;

    protected function setUp(): void
    {
        $this->normalizer = new FormErrorNormalizer();

        $this->form = $this->createMock(FormInterface::class);
        $this->form->method('isSubmitted')->willReturn(true);
        $this->form->method('all')->willReturn([]);

        $this->form->method('getErrors')
            ->willReturn(new FormErrorIterator($this->form, [
                new FormError('a', 'b', ['c', 'd'], 5, 'f'),
                new FormError(1, 2, [3, 4], 5, 6),
            ])
            );
    }

    public function testSupportsNormalizationWithWrongClass()
    {
        $this->assertFalse($this->normalizer->supportsNormalization(new \stdClass()));
    }

    

        throw new BadMethodCallException('Buttons cannot have children.');
    }

    public function all(): array
    {
        return [];
    }

    public function getErrors(bool $deep = false, bool $flatten = true): FormErrorIterator
    {
        return new FormErrorIterator($this[]);
    }

    /** * Unsupported method. * * This method should not be invoked. * * @return $this */
    public function setData(mixed $modelData)static
    {
        
Home | Imprint | This part of the site doesn't use cookies.