setIsEmptyCallback example

->setCompound($options['compound'])
            ->setData($isDataOptionSet ? $options['data'] : null)
            ->setDataLocked($isDataOptionSet)
            ->setDataMapper($options['compound'] ? $this->dataMapper : null)
            ->setMethod($options['method'])
            ->setAction($options['action']);

        if ($options['trim']) {
            $builder->addEventSubscriber(new TrimListener());
        }

        $builder->setIsEmptyCallback($options['is_empty_callback']);
    }

    /** * @return void */
    public function buildView(FormView $view, FormInterface $form, array $options)
    {
        parent::buildView($view$form$options);

        $name = $form->getName();
        $helpTranslationParameters = $options['help_translation_parameters'];

        
$event->getForm()->getViewData();
        });
        $form = new Form($config);

        $form->setData('foo');
    }

    public function testIsEmptyCallback()
    {
        $config = new FormConfigBuilder('foo', null, new EventDispatcher());

        $config->setIsEmptyCallback(fn ($modelData): bool => 'ccc' === $modelData);
        $form = new Form($config);
        $form->setData('ccc');
        $this->assertTrue($form->isEmpty());

        $config->setIsEmptyCallback(fn (): bool => false);
        $form = new Form($config);
        $form->setData(null);
        $this->assertFalse($form->isEmpty());
    }

    private function createForm(): FormInterface
    {
Home | Imprint | This part of the site doesn't use cookies.