define form fields.

@param FormBuilderInterface $builder
@param array                $options
327021
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $viewToIdTransformer = new ViewToIdTransformer($this->entityManager);

        $builder
            ->add($builder
                ->create('blog', HiddenType::class, ['label' => 'form.article.blog.label'])
                ->addModelTransformer($viewToIdTransformer))
            ->add('template')
            ->add('promoted', CheckboxType::class, [
                'label'    => 'form.article.type.promoted.label',
                'required' => false,
            ])
            ->add('tags', TagsType::class, [
                'required' => false,
                'multiple' => true,
            ])
            ->add('author', null, [
                'label'         => 'form.article.type.author.label',
                'required'      => true,
                'query_builder' => function (EntityRepository $er) {
                    return $er->createQueryBuilder('user')
                        ->where('user.roles LIKE :roles')
                        ->setParameter('roles', '%ROLE_VICTOIRE%');
                },
            ])
            ->remove('visibleOnFront');

        $builder->get('blog')->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
            $data = $event->getData();
            $parent = $event->getForm()->getParent();
            $this->manageCategories($data, $parent);
            $this->manageTemplate($data, $parent);
            $this->manageLocales($data, $parent);
        });

        $builder->get('blog')->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) {
            $data = $event->getData();
            $parent = $event->getForm()->getParent();
            $this->manageCategories($data, $parent);
            $this->manageLocales($data, $parent);
        });

        $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
            $data = $event->getData();
            $form = $event->getForm();
            $this->manageTags($data, $form);
        });
        $builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) {
            $form = $event->getForm();
            $data = $form->getData();
            $this->manageTags($data, $form);
        });
    }
287771
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('pageName', null, array(
            'label' => 'pages_controller_label_page_name',
        ));
        $builder->add('template', 'choice', array(
            'choices' => ChoiceValues::getTemplates($this->activeTheme, $this->themes),
            'label' => 'pages_controller_label_template',
        ));
        $builder->add('isHome', 'checkbox', array(
            'label' => 'pages_controller_label_home_page',
            'attr' => array(
                'title' => 'pages_controller_home_page_explanation',
            ),
        ));
        $builder->add('isPublished', 'checkbox', array(
            'label' => 'pages_controller_label_published',
        ));
    }
338167
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        parent::buildForm($builder, $options);
        $builder->add('title', null, [
                'label'    => 'widget_richlist.form.title.label',
                'required' => true,
            ])
            ->add('description', TextareaType::class, [
                'label'    => 'widget_richlist.form.description.label',
                'required' => true,
            ])
            ->add('kind', null, [
                'label'    => 'widget_richlist.form.kind.label',
                'required' => true,
            ])
            ->add('image', MediaType::class, [
                'label'    => 'widget_richlist.form.image.label',
                'required' => false, ])
            ->add('image2', MediaType::class, [
                'label'    => 'widget_richlist.form.image2.label',
                'required' => false, ])
            ->add('link', LinkType::class)
            ->add('linkLabel', null, [
                'label'    => 'form.widget_richlist.linkLabel.label',
                'required' => false,
            ])
            ->add('linkEnabled', CheckboxType::class, [
                    'label'    => 'form.widget_richlist.linkEnabled.label',
                    'required' => false,
                    'attr'     => [
                        'onchange' => 'linkEnable($vic(this).is(\':checked\']);',
                    ],
            ]);
    }
510757
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add(
            'family',
            FamilySelectorType::class,
            [
                'label' => false,
                'families' => $options['allowed_families'],
                'placeholder' => 'sidus.family.selector.placeholder',
            ]
        );
        $builder->addEventListener(
            FormEvents::PRE_SET_DATA,
            function (FormEvent $event) use ($options) {
                $form = $event->getForm();
                /** @var DataInterface $data */
                $data = $event->getData();

                /** @var FamilyInterface[] $families */
                $families = $options['allowed_families'];
                foreach ($families as $family) {
                    $selected = false;
                    if ($data instanceof DataInterface) {
                        $selected = $family->getCode() === $data->getFamilyCode();
                    }
                    $form->add(
                        'data_'.$family->getCode(),
                        AutocompleteDataSelectorType::class,
                        [
                            'label' => false,
                            'allowed_families' => [$family],
                            'auto_init' => $selected,
                            'attr' => [
                                'data-family' => $family->getCode(),
                                'style' => 'display:none',
                            ],
                        ]
                    );
                }
            }
        );

        $builder->addModelTransformer(
            new CallbackTransformer(
                function ($originalData) {
                    if ($originalData instanceof DataInterface) {
                        return [
                            'family' => $originalData->getFamily(),
                            'data_'.$originalData->getFamilyCode() => $originalData,
                        ];
                    }

                    return $originalData;
                },
                function ($submittedData) {
                    $family = $submittedData['family'];
                    if ($family instanceof FamilyInterface) {
                        return $submittedData['data_'.$family->getCode()];
                    }

                    return null;
                }
            )
        );
    }
410440
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        /** @var AttributeInterface $attribute */
        $attribute = $options['attribute'];

        $builder
            ->add(
                'enabled',
                CheckboxType::class,
                [
                    'widget_checkbox_label' => 'label',
                ]
            )
            ->add(
                'column',
                TextType::class,
                [
                    'data' => $attribute->getCode(),
                ]
            );

        if ($attribute->getType()->isRelation()) {
            $builder->add(
                'serializedColumn',
                ChoiceType::class,
                [
                    'choices' => [
                        'EAV Identifier' => 'identifier',
                        'Doctrine Id' => 'id',
                        'Label (WARNING: not re-importable)' => 'label',
                    ],
                ]
            );
        }
    }
158212
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        // title
        $builder->add('title', SymfonyTextType::class, array(
            'required' => false
        ));

        // headline (on demand)
        if (!empty($options['headline']['enabled'])) {
            $builder->add('headline', TextareaType::class, array(
                'required' => false
            ));
        }

        // text (rich editor or not)
        $builder->add('text', TextareaType::class, array(
            'attr' => array(
                'class' => empty($options['html']['enabled'])
                    ? 'synapse-simple-editor'
                    : 'synapse-rich-editor',
                'data-editor-config' => json_encode($options['ckeditor_config']),
            ),
        ));

        // image select (on demand)
        if (!empty($options['images'])) {
            $builder->add('images', ImageChoiceType::class, array(
                'image_formats' => $options['images']['format'],
                'required' => false,
                'expanded' => false,
                'multiple' => !empty($options['images']['multiple']),
            ));
        }

        // "Read more" link (on demand)
        if (!empty($options['read_more']['enabled'])) {
            $builder
                ->add('link', SymfonyTextType::class, array(
                    'required' => false,
                ))
                ->add('link_label', SymfonyTextType::class, array(
                    'required' => false,
                ))
            ;
        }
    }
1079405
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $format = $options['format'];

        $builder->addViewTransformer(
            new DateTimeToStringTransformer($options['date_timezone'], $options['user_timezone'], $format)
        );

        if ('string' === $options['input']) {
            $builder->addModelTransformer(new ReversedTransformer(
                new DateTimeToStringTransformer($options['date_timezone'], $options['date_timezone'], $format)
            ));
        } elseif ('timestamp' === $options['input']) {
            $builder->addModelTransformer(new ReversedTransformer(
                new DateTimeToTimestampTransformer($options['date_timezone'], $options['date_timezone'])
            ));
        } elseif ('array' === $options['input']) {
            $builder->addModelTransformer(new ReversedTransformer(
                new DateTimeToArrayTransformer($options['date_timezone'], $options['date_timezone'], array('year', 'month', 'day'))
            ));
        }
    }
610578
public function buildForm(FormBuilderInterface $builder, array $options)
	{
		$builder->add('name', TextType::class, array(
			'label' => 'Config name',
			'required' => true
		))
		->add('alias', TextType::class, array(
			'label' => 'Alias (interal use)',
			'required' => true 
		))
		->add('parameters', BaseCollectionType::class, array(
			'entry_type' => ParameterType::class,
			'label' => 'List of parameters',
			'allow_add' => true,
			'allow_delete' => true,
			'prototype' => true,
			'containerId' => 'parameters-collection'
		))
		->add('isDefault', CheckboxType::class, array(
			'label' => 'Configuration par défaut'
		));
	}
10363
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        parent::buildForm($builder, $options);

        $transformerStrategy = $options['transformer'];
        if ($transformerStrategy === 'auto') {
            $transformerStrategy = $options['multiple'] ? 'multiple' : 'class';
        }

        switch ($transformerStrategy) {
            case 'class':
                $builder->addViewTransformer(new ClassTransformer($this->quicklist, $options['repo']));
                break;

            case 'none':
                $builder->addViewTransformer(new NoneTransformer($this->quicklist, $options['repo']));
                break;

            case 'multiple':
                $builder->addViewTransformer(new MultipleTransformer(new ClassTransformer($this->quicklist, $options['repo'])));
                break;

            case 'multiple_none':
                $builder->addViewTransformer(new MultipleTransformer(new NoneTransformer($this->quicklist, $options['repo'])));
                break;
        }
    }
856035
public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $this->assertOptionsAreValid($options);

        foreach ($options['options'] as $i => $option) {
            if (!$option instanceof ProductOptionInterface) {
                throw new InvalidConfigurationException(
                    sprintf('Each object passed as option list must implement "%s"', ProductOptionInterface::class)
                );
            }

            $builder->add((string) $option->getCode(), ProductOptionValueChoiceType::class, [
                'label' => $option->getName() ?: $option->getCode(),
                'option' => $option,
                'property_path' => '[' . $i . ']',
                'block_name' => 'entry',
            ]);
        }
    }
1225429
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        parent::buildForm($builder, $options);
        $builder->get('value')->addModelTransformer(new StringToDateTimeTransformer('1'));
    }
397830
protected function addCriteriasFields($builder, $options)
    {
        $builder->add('criterias', CriteriaCollectionType::class, [
            'label'         => 'victoire.widget.type.criterias.label',
            'entry_type'    => CriteriaType::class,
            'required'      => false,
            'entry_options' => [
                'dataSources' => $options['dataSources'],
            ],
        ]);
        $builder->addEventListener(
            FormEvents::PRE_SET_DATA,
            function (FormEvent $event) use ($options) {
                $dataSources = $options['dataSources']->getDataSources();
                $widget = $event->getData();
                foreach ($dataSources as $alias => $dataSource) {
                    if (!$widget->hasCriteriaNamed($alias)) {
                        $criteria = new Criteria();
                        $criteria->setName($alias);
                        $widget->addCriteria($criteria);
                    }
                }
            }
        );
        $builder->addEventListener(
            FormEvents::POST_SUBMIT,
            function (FormEvent $event) use ($options) {
                $widget = $event->getData();
                /** @var Criteria $criteria */
                foreach ($widget->getCriterias() as $criteria) {
                    if ($criteria->getValue() === null) {
                        $widget->removeCriteria($criteria);
                    }
                }
            }
        );
    }
493382
public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        // Get the context and membership provider to pass into transformer.
        $context = $this->production_context;
        $provider = $this->membership_provider;

        $builder
            ->add('optional', null, [
                'label' => 'invitation.form.optional',
            ])
            ->add('invitee', ChoiceType::class, [
                'label' => 'invitation.form.invitee',
                'placeholder' => 'invitation.form.choose_invitee',
                'choice_translation_domain' => false,

                // Load all active memberships for a production as choices.
                'choice_loader' => new CallbackChoiceLoader(function () use ($context, $provider) {
                    foreach ($provider->loadActiveMembershipsByProduction($context->getContext()) as $membership) {
                        $member = $membership->getMember();
                        yield $member->__toString() => $member->getUsername();
                    }
                }),
            ])
        ;
    }
198960
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        parent::buildForm($builder, $options);
        $builder->add('status', ChoiceType::class, [
            'label'   => 'form.page.type.status.label',
            'choices' => [
                'page.status.label.draft'       => PageStatus::DRAFT,
                'page.status.label.published'   => PageStatus::PUBLISHED,
                'page.status.label.unpublished' => PageStatus::UNPUBLISHED,
                'page.status.label.scheduled'   => PageStatus::SCHEDULED,
            ],
            'choices_as_values' => true,
        ])
        ->add('publishedAt', null, [
            'widget'             => 'single_text',
            'vic_datetimepicker' => true,
        ]);
    }
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;
                }
            )
        );
    }
870752
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->addModelTransformer($this)

            ->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($builder, $options) {
                $form = $event->getForm();
                $zone = $event->getData();

                // Create a component form for each into given zone
                $form->add('components', CollectionType::class, array(
                    'auto_initialize' => false,
                    'allow_add' => false,
                    'allow_delete' => false,
                    'entry_type' => ComponentType::class,
                    'entry_options' => array(
                        'variation' => $this->variationResolver->resolve((new VariationContext())->denormalize(array(
                            'theme' => $options['theme'],
                            'content_type' => $options['content_type'],
                            'template_type' => $options['template_type'],
                            'zone_type' => $zone->getZoneType(),
                        ))),
                    ),
                ));
            })
        ;
    }
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);
                }
            }
        );
    }