Build the form.

@param FormBuilderInterface $builder
@param array                $options
10281
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        if (!$options['data'] || null === $options['data']->getId()) {
            $options['provider']->buildCreateForm($builder, $options);
        } else {
            $options['provider']->buildEditForm($builder, $options);
        }

        $builder->add('provider', HiddenType::class, ['data' => $options['provider']->getName()]);
    }
295834
public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $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('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,
            ])
        ;
    }
359263
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $categories = $this->filterQueryHandler->handle($options['widget'], BlogCategory::class);

        //getAll categories
        $categoryQb = $this->getEntityManager()->getRepository('VictoireBlogBundle:BlogCategory')->getAll();
        //getAll published articles
        $articleQb = $this->getEntityManager()->getRepository('VictoireBlogBundle:Article')->getAll(true);

        //get Listing
        $listing = $options['widget']->getListing();

        $mode = $listing->getMode();
        switch ($mode) {
            case 'query':
                //filter with listingQuery
                $articleQb->filterWithListingQuery($listing->getQuery());
                break;
        }
        $categoryQb->filterByArticles($articleQb->getInstance('article'));
        $categories = $categoryQb->getInstance('c_category')->getQuery()->getResult();

        //the blank value
        $categoriesChoices = [];

        foreach ($categories as $category) {
            $categoriesChoices[$category->getTitle()] = $category->getId();
        }

        $data = null;
        if ($this->getRequest()->query->has('filter') && array_key_exists('category_filter', $this->getRequest()->query->get('filter'))) {
            if ($options['multiple']) {
                $data = [];
                foreach ($this->getRequest()->query->get('filter')['category_filter']['category'] as $id => $selectedCategory) {
                    $data[$id] = $selectedCategory;
                }
            } else {
                $data = $this->getRequest()->query->get('filter')['category_filter']['category'];
            }
        }

        $builder
            ->add(
                'category',
                ChoiceType::class,
                [
                    'label'       => false,
                    'choices'     => $categoriesChoices,
                    'required'    => false,
                    'expanded'    => true,
                    'multiple'    => $options['multiple'],
                    'placeholder' => $this->translator->trans('blog.category_filter.empty_value.label'),
                    'data'        => $data,
                ]
            );
    }
1139227
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('sitemapPriority', ChoiceType::class, [
                'label'   => 'sitemap.form.priority.label',
                'choices' => array_combine(range(0, 1, 0.1), range(0, 1, 0.1)),
            ])
            ->add('sitemapIndexed', CheckboxType::class, [
                'label' => false,
            ]);
    }
1105739
public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $resource = $options['data'];
        $builder
            ->add('media', MediaType::class, [
                'label' => 'resource.form.file',
                'provider' => 'sonata.media.provider.file',
                'context' => 'default',
                'translation_domain' => BkstgResourceBundle::TRANSLATION_DOMAIN,
            ])
            ->add('name', TextType::class, [
                'label' => 'resource.form.name',
            ])
            ->add('description', CKEditorType::class, [
                'label' => 'resource.form.description',
                'config' => ['toolbar' => 'basic'],
                'required' => false,
            ])
            ->add('active', ChoiceType::class, [
                    // Show "unpublished" instead of active.
                    'choice_loader' => new CallbackChoiceLoader(function () use ($resource) {
                        yield 'resource.form.status_choices.active' => true;
                        if (!$resource->isPublished()) {
                            yield 'resource.form.status_choices.unpublished' => false;
                        } else {
                            yield 'resource.form.status_choices.archived' => false;
                        }
                    }),
                    'label' => 'resource.form.status',
            ])
            ->add('pinned', CheckboxType::class, [
                'label' => 'resource.form.pinned',
                'required' => false,
            ])
        ;
    }
55558
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $choices = array(
            'LIKE %...%' => AbstractQueryBuilder::OPERATOR_CONTAINS,
            '=' => AbstractQueryBuilder::OPERATOR_EQUALS,
        );
        if ($options['addNullTransformer']) {
            $choices['IS NULL'] = AbstractQueryBuilder::OPERATOR_IS_NULL;
            $choices['IS NOT NULL'] = AbstractQueryBuilder::OPERATOR_IS_NOT_NULL;
        }
        $builder
            ->add('transformer', ChoiceType::class, array_merge(array(
                'choices' => $choices,
            ), $options['transformerOptions']))
            ->add('value', TextType::class, array_merge(array(
                'required' => false,
            ), $options['valueOptions']));
    }
1309348
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        global $kernel;

        // get all modules
        $modules = array();

        $dir = $kernel->getRootDir().'/../src/Terrific/Module/';

        $finder = new Finder();
        $finder->directories()->in($dir)->depth('== 0');

        foreach ($finder as $file) {
            $filename = $file->getFilename();
            $module = str_replace('Bundle', '', $filename);
            $modules[$module] = $module;
        }

        $builder->add('module', 'choice', array(
            'choices' => $modules,
            'multiple' => false,
            'label' => 'Skin for Module'
        ));
        $builder->add('name', 'text');
        $builder->add('style', 'choice', array(
            'choices' => array('css' => 'CSS', 'less' => 'LESS'),
            'multiple' => false,
            'expanded' => true
        ));
    }
124912
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $this->addWalletType($builder, $options[SubFormInterface::OPTIONS_FIELD_NAME][static::OPTION_WALLET_CHOICES]);
    }
174767
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        parent::buildForm($builder, $options);

        $this->addBankGroupType($builder, $options);
    }
1152797
public function buildForm(FormBuilderInterface $builder, array $options)
	{
		$builder->add('name', TextType::class, array(
			'label' => 'Parameter name',
			'required' => true
		))
		->add('value', TextType::class, array(
			'label' => 'Parameter value',
			'required' => true,
		));
		
		$builder->add('config', HiddenType::class, array(
			'required' => true
		));
		
		$builder->get('config')->addModelTransformer(new IdToConfigTransformer($this->configManager));
	}
97467
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->addModelTransformer($this)
            ->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($builder, $options) {
                $form = $event->getForm();
                $data = array(
                    'template_types' => null,
                    'templates' => array(),
                );

                // "templates"  field
                $templateFormBuilder = $builder->create('templates', null, array(
                    'compound' => true,
                    'auto_initialize' => false,
                ));
                $templateTypeChoices = array();

                // every template type got his own form
                foreach ($options['theme']->getTemplateTypes() as $templateType) {

                    // variation calculation
                    $variation = $this->variationResolver->resolve((new VariationContext())->denormalize(array(
                        'theme' => $options['theme'],
                        'content_type' => $contentType = $options['content_type'],
                        'template_type' => $templateType,
                    )));
                    if (!$templateType->supportsContentType(
                        $contentType->getName(),
                        $variation->getConfiguration('templates', $templateType->getName(), 'contents', array())
                    )) {
                        continue;
                    }

                    // template select entry
                    $templateTypeChoices[$templateType->getId()] = $templateType;

                    // template form construction
                    $template = $options['content']
                        ? $this->templateLoader->retrieveLocal($templateType, $options['content'])
                        : $this->templateLoader->retrieveGlobal($templateType, $contentType)
                    ;
                    if (!$template) {  // no template to edit : nothing to do
                        continue;
                    }

                    $data['templates'][$templateType->getName()] = $template;

                    $templateFormBuilder->add($templateType->getName(), TemplateType::class, array(
                        'auto_initialize' => false,
                        'content_type' => $options['content_type'],
                        'theme' => $options['theme'],
                        'template_type' => $templateType,
                        'variation' => $variation,
                    ));
                }

                $form
                    ->add('template_types', ChoiceType::class, array(
                        'required' => true,
                        'expanded' => false,
                        'auto_initialize' => false,
                        'choices' => $templateTypeChoices,
                        'mapped' => false,
                        'choice_value' => 'name',
                        'choice_label' => 'name',
                    ))
                    ->add($templateFormBuilder->getForm())
                ;

                $event->setData($data);
            })
        ;
    }
1151856
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
            $view = $event->getData();
            $form = $event->getForm();

            $this->isNew = !$view || null === $view->getId();

            if ($this->isNew) {
                $getAllTemplateWithoutMe = function (EntityRepository $tr) {
                    return $tr->getAll()->getInstance();
                };
            } else {
                $getAllTemplateWithoutMe = function (EntityRepository $tr) use ($view) {
                    return $tr->getAll()
                        ->getInstance()
                        ->andWhere('template.id != :templateId')
                        ->setParameter('templateId', $view->getId());
                };
            }
            if (!$form->has('template')) {
                $form->add('template', null, [
                    'label'        => 'form.view.type.template.label',
                    'choice_label' => function ($view) {
                        return $view->getName();
                    },
                    'required'      => !$view instanceof Template || $view instanceof BusinessTemplate,
                    'query_builder' => $getAllTemplateWithoutMe,
                ]);
            }

            //If view is an Article BEP, we do not allow to choose parent because it will be set automatically
            if (!$view instanceof ArticleTemplate && ClassUtils::getClass($view) != 'Victoire\Bundle\TemplateBundle\Entity\Template') {
                if (!$view || null === $view->getId()) {
                    $getAllPageWithoutMe = function (EntityRepository $repo) {
                        return $repo->getAll()->getInstance();
                    };
                } else {
                    $getAllPageWithoutMe = function (EntityRepository $repo) use ($view) {
                        return $repo->getAll()
                            ->getInstance()
                            ->andWhere('view.id != :pageId')
                            ->setParameter('pageId', $view->getId());
                    };
                }

                $form->add('parent', null, [
                        'class'         => 'Victoire\Bundle\PageBundle\Entity\BasePage',
                        'label'         => 'form.view.type.parent.label',
                        'query_builder' => $getAllPageWithoutMe,
                        'required'      => true,
                    ]
                );
            }

            if ($view instanceof BasePage) {
                $translationOptions = [
                    'fields' => [
                        'name' => [
                            'label' => 'form.view.type.name.label',
                        ],
                    ],
                ];
                if ($view->getId() && !$view->isHomepage()) {
                    $translationOptions['fields']['slug'] = [
                        'label'      => 'form.page.type.slug.label',
                        'field_type' => UrlvalidatedType::class,
                    ];
                }
                $form->add('translations', TranslationsType::class, $translationOptions);
            }
        });

        if ($this->authorizationChecker->isGranted('ROLE_VICTOIRE_DEVELOPER')) {
            $builder->add('roles', TextType::class, [
                'label'          => 'form.page.type.roles.label',
                'vic_help_block' => 'form.page.type.roles.help_block',
            ]);
        }
    }
802039
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $this->buildValuesForm($builder, $options);
        $this->buildDataForm($builder, $options);

        $builder->addEventListener(
            FormEvents::POST_SUBMIT,
            function (FormEvent $event) {
                $data = $event->getData();
                if ($data instanceof DataInterface) {
                    $data->setUpdatedAt(new \DateTime());
                }
            }
        );
    }
1183435
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add(
                self::START_NAME,
                DatePickerType::class,
                [
                    'widget_position' => 'left',
                    'attr' => [
                        'class' => 'input-sm form-control',
                        'placeholder' => 'sidus.filter.date_range.start_date',
                    ],
                ]
            )
            ->add(
                self::END_NAME,
                DatePickerType::class,
                [
                    'attr' => [
                        'class' => 'input-sm form-control',
                        'placeholder' => 'sidus.filter.date_range.end_date',
                    ],
                ]
            );
    }
971538
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('richs', CollectionType::class, [
            'entry_type' => WidgetRichListItemType::class,
            'allow_add' => true,
            'allow_delete' => true,
            'by_reference' => false,
            'entry_options' => [
                'namespace'        => $options['namespace'],
                'businessEntityId' => $options['businessEntityId'],
                'widget'           => $options['widget'],
            ],
            'attr' => ['id' => 'static'],
        ]);

        //add the mode to the form
        $builder->add('mode', HiddenType::class, [
            'data' => $options['mode'],
        ]);

        //add the slot to the form
        $builder->add('slot', HiddenType::class, []);
        $this->addCriteriasFields($builder, $options);

        $builder->add('quantum', QuantumType::class, [
            'label'    => 'victoire.widget.type.quantum.label',
            'attr'     => [
                'data-flag' => 'v-quantum-name',
            ],
        ]);
    }
545511
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('day_of_week_numbers', 'choice', array(
                'choices'   => DayOfWeek::getChoices(),
                'multiple'  => true,
                'expanded'  => true,
                'label'     => 'Days of Week',
            ))
            ->add('start_time', 'choice', array(
                'choices'   => WindowMaker::getStartTimeChoices(),
            ))
            ->add('end_time', 'choice', array(
                'choices'   => WindowMaker::getEndTimeChoices(),
            ))
            ->add('delivery_type', 'choice', array(
                'choices' => array(
                  HubWindow::DELIVERY_TYPE_PICKUP   => 'Pickup',
                  HubWindow::DELIVERY_TYPE_DELIVERY => 'Delivery',
                ),
                'multiple'  => false,
                'expanded'  => true,
            ))
        ;
    }
141763
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $templateType = $options['template_type'];
        $variation = $options['variation'];

        $builder
            ->addModelTransformer($this)

            // build template zones
            ->add('zones', CollectionType::class, array(
                'allow_add' => false,
                'allow_delete' => false,
                'entry_type' => ZoneType::class,
                'entry_options' => array(
                    'theme' => $options['theme'],
                    'content_type' => $options['content_type'],
                    'template_type' => $options['template_type'],
                ),
            ))

            // zone type selection (unmapped, frontend use case - should be defined in Twig layout ?)
            ->add('zone_types', ChoiceType::class, array(
                'mapped' => false,
                'required' => true,
                'expanded' => false,
                'choices' => $templateType->getZoneTypes()->indexBy('name'),
                'choice_value' => 'name',
                'choice_label' => 'name',

                // main zone by default
                'data' => $templateType->getZoneTypes()
                    ->filter(function (ZoneTypeInterface $zoneType) use ($variation) {
                        return $variation->getConfiguration(
                            'zones', $zoneType->getName(), 'main', false
                        );
                    })
                    ->first() ?: null,
            ))
        ;
    }