Configures a Comment form.

@param FormBuilderInterface $builder
@param array                $options
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])
        ;
    }
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,
                ]
            );
    }
1297364
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        if (null !== $this->parent) {
            $this->parent->buildForm($builder, $options);
        }

        $this->innerType->buildForm($builder, $options);

        foreach ($this->typeExtensions as $extension) {
            $extension->buildForm($builder, $options);
        }
    }
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());
                }
            }
        );
    }
908413
public function buildForm(FormBuilderInterface &$builder, array $options, array $data)
    {
        $this->addStandardFormFields('contactsource', 'categories', $builder, $data);
        $this->addExtendedFormFields('contactsource', 'items', $builder, $data);
        //This is in anticipation of PR 5995 getting merged ~2.16
        if (method_exists($this, 'addCustomFormFields')) {
            $addCustomFormFields = 'addCustomFormFields';
            $this->$addCustomFormFields($this->getName(), 'export', $builder, 'mautic.core.permissions.export', ['disable' => 'mautic.core.permissions.disable'], $data);
        }
    }
1184633
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $articles = $this->getEntityManager()->getRepository('VictoireBlogBundle:Article')->getAll(true)->run();
        $years = $months = $days = [];
        foreach ($articles as $key => $_article) {
            $years[$_article->getPublishedAt()->format('Y')] = $_article->getPublishedAt()->format('Y');

            if ($options['widget']->getFormat() != 'year') {
                //init $months array
                if (!isset($months[$_article->getPublishedAt()->format('Y')])) {
                    $months[$_article->getPublishedAt()->format('Y')] = [];
                }
                $months[$_article->getPublishedAt()->format('Y')][] = $_article->getPublishedAt()->format('M');
                if ($options['widget']->getFormat() != 'month') {
                    //init $days array
                    if (!isset($days[$_article->getPublishedAt()->format('M')])) {
                        $days[$_article->getPublishedAt()->format('M')] = [];
                    }
                    //assign values
                    $days[$_article->getPublishedAt()->format('M')][] = $_article->getPublishedAt()->format('M');
                }
            }
        }

        ksort($years);

        $data = ['year' => null, 'month' => null, 'day' => null];
        if ($this->getRequest()->query->has('filter') && array_key_exists('date_filter', $this->getRequest()->query->get('filter'))) {
            $_request = $this->getRequest()->query->get('filter')['date_filter'];
            $data = $_request;
        }

        if (in_array($options['widget']->getFormat(), ['year', 'month', 'day'])) {
            if (!$data['year']) {
                // set default value to date filter and set listing to request while not better way
                $data['year'] = $options['widget']->getDefaultValue();
                $this->getRequest()->query->replace(
                    [
                        'filter' => [
                            self::class => [
                                'year' => $options['widget']->getDefaultValue(),
                            ],
                        'listing' => $options['widget']->getListing()->getId(),
                        ],
                    ]
                );
            }
            $builder
                ->add(
                    'year', ChoiceType::class, [
                        'label'       => false,
                        'choices'     => $years,
                        'required'    => false,
                        'expanded'    => false,
                        'multiple'    => false,
                        'placeholder' => false,
                        'data'        => $data['year'],
                    ]
                );
        }
    }
917147
public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $schedule = $options['data'];
        $builder
            ->add('name', null, [
                'label' => 'schedule.form.name',
            ])
            ->add('location', null, [
                'label' => 'schedule.form.location',
            ])
            ->add('description', CKEditorType::class, [
                'label' => 'schedule.form.description',
                'config' => ['toolbar' => 'basic'],
                'required' => false, ])
            ->add('colour', ChoiceType::class, [
                'label' => 'schedule.form.colour',
                'required' => false,
                'choices' => [
                    'schedule.form.colour_choices.red' => 'important',
                    'schedule.form.colour_choices.green' => 'success',
                    'schedule.form.colour_choices.yellow' => 'warning',
                    'schedule.form.colour_choices.blue' => 'info',
                    'schedule.form.colour_choices.dark' => 'inverse',
                    'schedule.form.colour_choices.purple' => 'special',
                ],
            ])
            ->add('active', ChoiceType::class, [
                // Show "unpublished" instead of active.
                'choice_loader' => new CallbackChoiceLoader(function () use ($schedule) {
                    yield 'schedule.form.status_choices.active' => true;
                    if (!$schedule->isPublished()) {
                        yield 'schedule.form.status_choices.unpublished' => false;
                    } else {
                        yield 'schedule.form.status_choices.archived' => false;
                    }
                }),
                'label' => 'schedule.form.status',
            ])
            ->add('events', CollectionType::class, [
                'label' => 'schedule.form.events',
                'entry_type' => ScheduleEventType::class,
                'entry_options' => ['label' => false],
                'allow_add' => true,
                'allow_delete' => true,
                'by_reference' => false,
            ])
        ;
    }
493308
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add(
            'familyCode',
            FamilySelectorType::class,
            [
                'label' => false,
                'placeholder' => 'permission.family.placeholder',
                'horizontal_input_wrapper_class' => 'col-sm-12',
            ]
        );
        foreach (FamilyPermission::getPermissions() as $permission) {
            $builder->add(
                $permission,
                CheckboxType::class,
                [
                    'widget_checkbox_label' => 'widget',
                    'horizontal_input_wrapper_class' => 'col-sm-1',
                ]
            );
        }

        $builder->get('familyCode')->addModelTransformer(
            new CallbackTransformer(
                function ($originalData) {
                    if (null === $originalData) {
                        return null;
                    }
                    // Ignoring missing family
                    if (!$this->familyRegistry->hasFamily($originalData)) {
                        return null;
                    }

                    return $this->familyRegistry->getFamily($originalData);
                },
                function ($submittedData) {
                    if ($submittedData instanceof FamilyInterface) {
                        return $submittedData->getCode();
                    }

                    return $submittedData;
                }
            )
        );
    }
1225429
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        parent::buildForm($builder, $options);
        $builder->get('value')->addModelTransformer(new StringToDateTimeTransformer('1'));
    }
1103172
protected function addEnabled(FormBuilderInterface $builder, array $options = [])
    {
        $enabledOptions = [
            Trans::__('page.edit-users.activated.yes') => 1,
            Trans::__('page.edit-users.activated.no')  => 0,
        ];

        $builder
            ->add(
                'enabled',
                ChoiceType::class,
                [
                    'choices_as_values' => true, // Can be removed when symfony/form:^3.0 is the minimum
                    'choices'           => $enabledOptions,
                    'expanded'          => false,
                    'constraints'       => new Assert\Choice(array_values($enabledOptions)),
                    'label'             => Trans::__('page.edit-users.label.user-enabled'),
                ] + $options
            )
        ;

        return $this;
    }
400125
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $this->getFormFieldsExtended($builder, $options, 'extendedField');
        $this->getFormFieldsExtended($builder, $options, 'extendedFieldSecure');
    }
246242
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('idPage', 'hidden', array('label' => 'pages_controller_label_permalink'));
        $builder->add('idLanguage', 'choice', array('choices' => ChoiceValues::getLanguages($this->languageRepository)));
        $builder->add('permalink', 'textarea', array(
            'label' => 'pages_controller_label_permalink',
            'attr' => array(
                'rows' => '3',
            ),));
        $builder->add('title', 'textarea', array(
            'label' => 'pages_controller_label_meta_title',
            'attr' => array(
                'title' => 'pages_controller_meta_title_explanation',
                'rows' => '3',
            ),
        ));
        $builder->add('description', 'textarea', array(
            'label' => 'pages_controller_label_meta_description',
            'attr' => array(
                'title' => 'pages_controller_meta_description_explanation',
                'rows' => '3',
            ),
        ));
        $builder->add('keywords', 'textarea', array(
            'label' => 'pages_controller_label_meta_keywords',
            'attr' => array(
                'title' => 'pages_controller_meta_keywords_explanation',
                'rows' => '2',
            ),
        ));
        $builder->add('sitemapChangeFreq', 'choice', array(
            'choices' => array(
                '' => '-',
                'always' => 'always',
                'hourly' => 'hourly',
                'daily' => 'daily',
                'weekly' => 'weekly',
                'monthly' => 'monthly',
                'yearly' => 'yearly',
                'never' => 'never',
            ),
            'label' => 'pages_controller_label_change frequency',
        ));
        $builder->add('sitemapPriority', 'choice', array(
            'choices' => array(
                '0.0' => '0.0',
                '0.1' => '0.1',
                '0.2' => '0.2',
                '0.3' => '0.3',
                '0.4' => '0.4',
                '0.5' => '0.5',
                '0.6' => '0.6',
                '0.7' => '0.7',
                '0.8' => '0.8',
                '0.9' => '0.9',
                '1.0' => '1.0',
            ),
            'data' => '0.5',
            'label' => 'pages_controller_label_priority',
        ));
    }
1101718
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $required = true;
        if ($options['data']->getId()) {
            $required = false;
        }
        $builder
            ->add('active', CheckboxType::class, array('label' => 'Aktiviert', 'required' => false))
            ->add('name', TextType::class, array('label' => 'Name'))
            ->add(
                'uploadedFile',
                FileType::class,
                array(
                    'label' => 'Upload',
                    'required' => $required,
                    'constraints' => array(
                        new File(array('maxSize' => "2M")),
                        //new Image(),
                    ),
                )
            );
    }
1210423
public function buildForm(FormBuilderInterface $builder, array $options)
	{
		$user_transformer = new StringToUserTransformer($this->userManager);
		$builder->addModelTransformer($user_transformer);
	}
381202
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        parent::buildForm($builder, $options);

        $builder->remove('translations');
        $builder->add('translations', TranslationsType::class, [
            'required_locales' => [],
            'fields'           => [
                'name' => [
                    'label'                        => 'form.view.type.name.label',
                    'vic_business_properties'      => $options['vic_business_properties'],
                    'vic_business_property_picker' => [
                        'description' => 'victoire.form.business_template.name.vic_business_property_picker',
                    ],
                ],
                'slug' => [
                    'label'                        => 'victoire.form.business_template.slug.label',
                    'vic_business_properties'      => $options['vic_business_properties'],
                    'vic_business_property_picker' => [
                        'description' => 'victoire.form.business_template.slug.vic_business_property_picker',
                    ],
                ],
            ],
        ]);
        $builder
            ->add('backendName', null, [
                'label'          => 'victoire.form.business_template.backend_name.label',
                'vic_help_block' => 'victoire.form.business_template.backend_name.help_block',
            ])
            ->add('query', null, [
                'label'                        => 'victoire.form.business_template.query.label',
                'vic_business_properties'      => $options['vic_business_properties'],
                'vic_business_property_picker' => [
                    'description' => false,
                ],
            ])
            ->add('businessEntityId', HiddenType::class);
    }
196584
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->addModelTransformer(new CallbackTransformer(
            function ($original) {
                $tree = $this->blockService->getTree($original);

                return json_encode($tree);
            },
            function ($submitted) {
                $array = json_decode($submitted, true);

                $stripped = $this->stripMetadata($array);

                return trim(json_encode($stripped));
            }
        ));
    }
333502
protected function buildUserForm(FormBuilderInterface $builder, array $options)
    {
        $now = new \DateTime();

        $builder
            ->add('username', null, array('label' => 'form.label_username', 'translation_domain' => 'SonataUserBundle'))
            ->add('email', 'email', array('label' => 'form.label_email', 'translation_domain' => 'SonataUserBundle', 'read_only'=>true, 'attr'=>array('class'=>'span12')))
            ->add('firstname', null, array('label' => 'form.label_firstname', 'translation_domain' => 'SonataUserBundle', 'attr'=>array('class'=>'span12')))
            ->add('lastname', null, array('label' => 'form.label_lastname','translation_domain' => 'SonataUserBundle', 'attr'=>array('class'=>'span12')))
            ->add('website', null, array('label' => 'form.label_website', 'translation_domain' => 'SonataUserBundle', 'attr'=>array('class'=>'span12')))
            ->add('phone', null, array('required' => false, 'label' => 'form.label_phone', 'translation_domain' => 'SonataUserBundle', 'attr'=>array('class'=>'span12')))
            ->add('dateOfBirth', 'sonata_type_date_picker', array(
                'years'       => range(1900, $now->format('Y')),
                'dp_min_date' => '1-1-1900',
                'dp_max_date' => $now->format('c'),
                'required'    => false,
            ))
            ->add('gender', 'choice', array(
                              'label' => 'form.label_gender',
                              'choices' => array(
                                  UserInterface::GENDER_UNKNOWN => 'gender_unknown',
                                  UserInterface::GENDER_FEMALE  => 'gender_female',
                                  UserInterface::GENDER_MAN     => 'gender_male',
                              ),
                              'required' => true,
                              'translation_domain' => 'SonataUserBundle',
                              'attr'=>array('class'=>'span12')
                          ));
    }