Stores a button for later rendering

@param ButtonBuilder        $buttonBuilder
@param FormBuilderInterface $form
@param string               $position
971098
protected function storeButton(ButtonBuilder $buttonBuilder, FormBuilderInterface $form, $position)
    {

        if (!isset($this->buttons[$form->getName()])) {
            $this->buttons[$form->getName()] = array();
        }

        $this->buttons[$form->getName()][$position] = $buttonBuilder;
    }
1254940
protected Button newSubmitButton(final String id, final Form<?> form)
	{
		final Button button = new AjaxFallbackButton(id, form)
		{
			/**
			 * The serialVersionUID
			 */
			private static final long serialVersionUID = 1L;

			/**
			 * {@inheritDoc}
			 */
			@Override
			protected void onError(final AjaxRequestTarget target, final Form<?> form)
			{
				BeanEditorPanel.this.onSubmit(target, form);
			}

			/**
			 * {@inheritDoc}
			 */
			@Override
			protected void onSubmit(final AjaxRequestTarget target, final Form<?> form)
			{
				BeanEditorPanel.this.onSubmit(target, form);
			}
		};
		return button;
	}
338887
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        if ($options['add_author']) {
            $builder->add('authorName', TextType::class, ['required' => true]);

            $this->vars['add_author'] = $options['add_author'];
        }

        if ($options['show_note']) {
            $builder->add('note', ChoiceType::class, [
                'required' => false,
                'choices' => $this->noteProvider->getValues(),
            ]);
        }

        $builder
            ->add('website', UrlType::class, ['required' => false])
            ->add('email', EmailType::class, ['required' => false])
        ;
    }
1015658
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        parent::buildForm($builder, $options);

        $builder->add('layout', ChoiceType::class, [
            'label'   => 'form.template.type.layout.label',
            'choices' => array_flip($options['layouts']),
        ]);

        $builder->add('translations', TranslationsType::class, [
            'fields' => [
                'name' => [
                    'label' => 'form.view.type.name.label',
                ],
            ],
        ]);

        $builder->remove('roles');
    }
1329945
private function createActionTab(FormBuilderInterface $builder)
    {
        return $builder->create('actions', TabsTabActionsType::class, array(
            'mapped' => false,
            'inherit_data' => true,
        ))
            ->add('save', SubmitType::class, array(
                'label' => 'node.form.tab.action.field.save',
                'attr' => array('class' => 'btn btn-success'),
            ));
    }
118675
public function button($name, $position="BL", $attributes=array())
    {
        $attributes = array_merge(array("class"=>"btn btn-default"), $attributes);

        $this->button_container[$position][] = Form::button($name, $attributes);

        return $this;
    }
1047878
private function finishWeight(FormInterface $form, $weight, $position = null)
    {
        if ($position === null) {
            foreach (array_keys($this->differed) as $position) {
                $weight = $this->finishWeight($form, $weight, $position);
            }
        } else {
            $name = $form->getName();

            if (isset($this->differed[$position][$name])) {
                $postIncrement = $position === 'before';

                foreach ($this->differed[$position][$name] as $differed) {
                    $this->processWeight($differed, $postIncrement ? $weight++ : ++$weight);
                }

                unset($this->differed[$position][$name]);
            }
        }

        return $weight;
    }
393268
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('containerTag', ChoiceType::class, [
                'label'          => 'widget_layout.form.containerTag.label',
                'vic_help_block' => 'widget_layout.form.containerTag.help_block',
                'choices'        => array_combine(Widget::$tags, Widget::$tags),
            ])
            ->add('containerClass', null, [
                'label'    => 'widget_layout.form.containerClass.label',
                'required' => false,
            ])
            ->add('vicActiveTab', HiddenType::class, [
                'required' => false,
                'mapped'   => false,
            ])
            ->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
                /*
                 * Generate form fields for each part of form
                 * Example, generate Static content, XS and SM as color forms
                 * Whereas MD and LG are image forms
                 */
                foreach ($this->victoire_twig_responsive as $key) {
                    self::generateBackgroundFields($event->getForm(), $key, $event->getData()->{'getContainerBackgroundType'.$key}());
                }
            });

        foreach ($this->victoire_twig_responsive as $key) {
            /*
             * Build global fields for all parts of form
             */
            $builder
                ->add('containerMargin'.$key, null, [
                    'label'          => 'widget_layout.form.containerMargin'.$key.'.label',
                    'vic_help_block' => 'widget_layout.form.containerMargin.help_block',
                    'required'       => false,
                ])
                ->add('containerPadding'.$key, null, [
                    'label'          => 'widget_layout.form.containerPadding'.$key.'.label',
                    'vic_help_block' => 'widget_layout.form.containerPadding.help_block',
                    'required'       => false,
                ])
                ->add('containerWidth'.$key, null, [
                    'label' => 'widget_layout.form.containerWidth'.$key.'.label',
                    'attr'  => ['placeholder' => 'widget_layout.form.containerWidth.placeholder'],
                ])
                ->add('containerHeight'.$key, null, [
                    'label' => 'widget_layout.form.containerHeight'.$key.'.label',
                    'attr'  => ['placeholder' => 'widget_layout.form.containerWidth.placeholder'],
                ])
                ->add('textAlign'.$key, ChoiceType::class, [
                    'label'    => 'widget_layout.form.textAlign'.$key.'.label',
                    'required' => false,
                    'choices'  => [
                        'widget_layout.form.textAlign.choices.left.label'    => 'left',
                        'widget_layout.form.textAlign.choices.center.label'  => 'center',
                        'widget_layout.form.textAlign.choices.right.label'   => 'right',
                        'widget_layout.form.textAlign.choices.justify.label' => 'justify',
                    ],
                    'placeholder'       => 'widget_layout.form.textAlign.choices.placeholder',
                    'choices_as_values' => true,
                ])
                ->add('containerBackgroundType'.$key, ChoiceType::class, [
                    'label'    => 'widget_layout.form.containerBackgroundType'.$key.'.label',
                    'required' => false,
                    'choices'  => [
                        'widget_layout.form.containerBackgroundType.choices.color.label' => 'color',
                        'widget_layout.form.containerBackgroundType.choices.image.label' => 'image',
                    ],
                    'placeholder'       => 'widget_layout.form.containerBackgroundType.choices.placeholder',
                    'choices_as_values' => true,
                    'attr'              => [
                        'data-refreshOnChange' => 'true',
                    ],
                ])
                ->get('containerBackgroundType'.$key)->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) use ($key) {
                    self::generateBackgroundFields($event->getForm()->getParent(), $key, $event->getData());
                });
        }

        // add theme field
        $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
            $data = $event->getData();
            $form = $event->getForm();
            //guess the bundle name
            $widgetBundle = self::getBundleNameFromEntity(get_class($data), $this->kernel->getBundles());
            //search for available theme files
            $finder = Finder::create()
                ->files()
                ->name('/^show(.)+\.html\.twig$/')
                ->in($this->fileLocator->locate('@'.$widgetBundle.'/Resources/views', null, false))
                ->sortByName();

            $choices = [];
            //prepare choices by adding in each theme
            foreach ($finder as $key => $file) {
                $theme = $file->getRelativePathname();
                $theme = preg_replace('/show|\.html\.twig/', '', $theme);
                $choices['victoire.'.$widgetBundle.'.theme.'.$theme.'.label'] = $theme;
            }
            //We add the theme type only if there is a choice
            if (count($choices)) {
                $form->add('theme', ChoiceType::class, [
                    'label'             => 'widget.form.theme.label',
                    'choices'           => $choices,
                    'choices_as_values' => true,
                    'placeholder'       => 'victoire.theme.default.label',
                ]);
            }
        });
    }
116765
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $this->addIBAN($builder)
            ->addBIC($builder);

        if (Store::getInstance()->getCurrentCountry() === 'DE') {
            $this->addBankAccount($builder)
                ->addBankCode($builder)
                ->addBankCountry($builder, $options)
                ->addModeSwitch($builder, $options);
        }
    }
1374829
public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $event = $options['data'];
        $builder
            ->add('start', null, [
                'label' => 'event.form.start',
                'date_widget' => 'single_text',
                'time_widget' => 'single_text',
            ])
            ->add('end', null, [
                'label' => 'event.form.end',
                'date_widget' => 'single_text',
                'time_widget' => 'single_text',
            ])
            ->add('name', null, [
                'label' => 'event.form.name',
            ])
            ->add('location', null, [
                'label' => 'event.form.location',
            ])
            ->add('description', CKEditorType::class, [
                'label' => 'event.form.description',
                'required' => false,
                'config' => ['toolbar' => 'basic'],
            ])
            ->add('full_company', CheckboxType::class, [
                'label' => 'event.form.full_company',
                'required' => false,
            ])
            ->add('invitations', CollectionType::class, [
                'label' => 'event.form.invitations',
                'entry_type' => InvitationType::class,
                'entry_options' => ['label' => false],
                'allow_add' => true,
                'allow_delete' => true,
                'by_reference' => false,
            ])
            ->add('colour', ChoiceType::class, [
                'label' => 'event.form.colour',
                'required' => false,
                'choices' => [
                    'event.form.colour_choices.red' => 'important',
                    'event.form.colour_choices.green' => 'success',
                    'event.form.colour_choices.yellow' => 'warning',
                    'event.form.colour_choices.blue' => 'info',
                    'event.form.colour_choices.dark' => 'inverse',
                    'event.form.colour_choices.purple' => 'special',
                ],
            ])
            ->add('active', ChoiceType::class, [
                // Show "unpublished" instead of active.
                'choice_loader' => new CallbackChoiceLoader(function () use ($event) {
                    yield 'event.form.status_choices.active' => true;
                    if (!$event->isPublished()) {
                        yield 'event.form.status_choices.unpublished' => false;
                    } else {
                        yield 'event.form.status_choices.archived' => false;
                    }
                }),
                'label' => 'event.form.status',
            ])
        ;
    }
338586
public function submit($name, $position = "BL", $options = array())
    {
        $options = array_merge(array("class" => "btn btn-primary"), $options);
        $this->button_container[$position][] = Form::submit($name, $options);

        return $this;
    }
354912
public function addForm(FormBuilderInterface $fb, Page $page)
    {
        $data = $page->getData() == "" ? 0 : $page->getData();
        $fb->add('mode', ChoiceType::class,[
            "label" => "sitemap.behavior",
            "translation_domain" => "forms",
            "choices" => [
                "sitemap.absolute" => 0,
                "sitemap.relative" => 1,
                "sitemap.subpages" => 2,
            ],
            "data" => $data["mode"],
            "mapped" => false
        ])
            ->add("limit", NumberType::class, [
                "label" => "sitemap.limit",
                "translation_domain" => "forms",
                "mapped" => false,
                "data" => $data["limit"],
                "required" => false
            ]);
        return $fb;
    }
963924
public function defineFormBuilder(FormBuilderInterface $formBuilder)
    {
        /** @var AbstractAdmin $admin */
        $admin = $this;

        $mapper = new \Compo\Sonata\AdminBundle\Form\FormMapper($admin->getFormContractor(), $formBuilder, $admin);

        $this->configureFormFields($mapper);

        foreach ($admin->getExtensions() as $extension) {
            $extension->configureFormFields($mapper);
        }

        $this->attachInlineValidator();
    }
1256503
protected function appendSingleFormFields(FormBuilderInterface $formBuilder)
    {
        $defaultOptions = [
            'label'    => $this->getTitle(),
            'required' => false,
        ];

        $userOptions = array_key_exists('single', $this->getFormOptions())
            ? $this->getFormOptions()['single']
            : [];

        if (count($userOptions) > 0) {
            $defaultOptions = array_merge($defaultOptions, $userOptions);
        }

        $defaultOptions['property_path'] = 'value';

        $formBuilder->add($this->getValuePropertyName(), $this->getFormFieldType(), $defaultOptions);

        return $this;
    }
69422
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('title', TextType::class, [
                'label'       => 'blog.form.title.label',
                'required'    => true,
                'constraints' => [
                    new \Symfony\Component\Validator\Constraints\NotBlank(),
                ],
                'attr' => [
                    'class' => 'vic-blogCategoryWidget-formControl',
                    ],
                ]
            )
            ->add('description', TextType::class, [
                'label'         => 'blog.form.description.label',
                'attr'          => [
                    'class'     => 'vic-blogCategoryWidget-formControl',
                ],
            ])
            ->remove('removeButton');

        /*
         * When we are editing a menu, we must add the sub menus if there are some children in the entity
         */
        $builder->addEventListener(
            FormEvents::PRE_SET_DATA,
            function (FormEvent $event) {
                $entity = $event->getData();

                if ($entity !== null) {
                    $nbChildren = count($entity->getChildren());

                    if ($nbChildren > 0) {
                        $form = $event->getForm();
                        $this->addChildrenField($form);
                    }
                }
            }
        );

        /*
         * we use the PRE_SUBMIT event to avoid having a circular reference
         *
         * This is done when a widget is created in js in the view
         */
        $builder->addEventListener(
            FormEvents::PRE_SUBMIT,
            function (FormEvent $event) {
                $rawData = $event->getData();
                if (isset($rawData['children'])) {
                    $addChildren = true;
                } else {
                    $addChildren = false;
                }

                //did some children was added in the form
                if ($addChildren) {
                    $form = $event->getForm();
                    $this->addChildrenField($form);
                }
            }
        );
    }
947462
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        //====================================================================//
        // Dispatch Object Listing Event
        $this->getEventDispatcher()->dispatch(FormListingEvent::NAME, new FormListingEvent($builder, $options));
    }
331079
public function getChildFormBuilder(FormBuilderInterface $formBuilder, $elementId)
    {
        foreach (new FormBuilderIterator($formBuilder) as $name => $formBuilder) {
            if ($name === $elementId) {
                return $formBuilder;
            }
        }
    }