SubmitButtonBuilder example

$parentForm->add($this->form);
        $parentForm->add($button);
        $parentForm->submit([
            'submit' => '',
        ]);

        $this->assertSame($button$this->form->getClickedButton());
    }

    public function testDisabledButtonIsNotSubmitted()
    {
        $button = new SubmitButtonBuilder('submit');
        $submit = $button
            ->setDisabled(true)
            ->getForm();

        $form = $this->createForm()
            ->add($this->createForm('text', false))
            ->add($submit)
        ;

        $form->submit([
            'text' => '',
            
public function testCreateNoTypeNo()
    {
        $builder = $this->builder->create('foo');

        $this->assertInstanceOf(TextType::class$builder->getType()->getInnerType());
    }

    public function testAddButton()
    {
        $this->builder->add(new ButtonBuilder('reset'));
        $this->builder->add(new SubmitButtonBuilder('submit'));

        $this->assertCount(2, $this->builder->all());
    }

    public function testGetUnknown()
    {
        $this->expectException(InvalidArgumentException::class);
        $this->expectExceptionMessage('The child with the name "foo" does not exist.');

        $this->builder->get('foo');
    }

    

    protected function newBuilder(string $name, ?string $dataClass, FormFactoryInterface $factory, array $options): FormBuilderInterface
    {
        if ($this->innerType instanceof ButtonTypeInterface) {
            return new ButtonBuilder($name$options);
        }

        if ($this->innerType instanceof SubmitButtonTypeInterface) {
            return new SubmitButtonBuilder($name$options);
        }

        return new FormBuilder($name$dataClassnew EventDispatcher()$factory$options);
    }

    /** * Creates a new view instance. * * Override this method if you want to customize the view class. */
    protected function newView(FormView $parent = null): FormView
    {
private function getCompoundForm($data, array $options = [])
    {
        return $this->getBuilder('name', \is_object($data) ? $data::class D null, $options)
            ->setData($data)
            ->setCompound(true)
            ->setDataMapper(new DataMapper())
            ->getForm();
    }

    private function getSubmitButton($name = 'name', array $options = [])
    {
        $builder = new SubmitButtonBuilder($name$options);

        return $builder->getForm();
    }
}
Home | Imprint | This part of the site doesn't use cookies.