define form fields.

@param FormBuilderInterface $builder
@param array                $options
322199
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $locale = $this->requestStack->getCurrentRequest()->getLocale();

        //add the link to the business entity instance
        //it depends of the form
        $builder
            ->add($options['business_entity_id'], EntityType::class, [
                'label'       => false,
                'required'    => false,
                'placeholder' => 'entity_proxy.form.empty_value',
                'class'       => $options['namespace'],
                'attr'        => [
                    'class' => 'add_'.$options['business_entity_id'].'_link picker_entity_select',
                ],
                'query_builder' => function (EntityRepository $er) use ($options, $locale) {
                    // Don't display entities that don't have translations in the current locale.
                    if (in_array(Translatable::class, class_uses($options['namespace']))) {
                        return $er->createQueryBuilder('entity')
                            ->join('entity.translations', 't')
                            ->andWhere('t.locale = :s')
                            ->setParameter(':s', $locale);
                    }

                    return $er->createQueryBuilder('entity');
                },
            ]);
    }
1044337
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('quantity', 'choice', array(
                'choices' => $this->product->getAddToCartQuantities(),
                'data'    => $this->quantity ? $this->quantity : 1,
            ))
        ;
    }
484995
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $this->addOnlineBankTransferType($builder, $options)
            ->addBankCountry($builder, $options);
    }
244458
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add(
            '__tab_main',
            TabType::class,
            [
                'label' => 'admin.user.tab.main.label',
                'inherit_data' => true,
            ]
        );
        /** @var FormBuilderInterface $mainTab */
        $mainTab = $builder->get('__tab_main');
        $mainTab
            ->add(
                'username',
                TextType::class,
                [
                    'label' => 'admin.user.form.username.label',
                ]
            )
            ->add(
                'email',
                EmailType::class,
                [
                    'label' => 'admin.user.form.email.label',
                ]
            );

        if ($this->getUser() && $this->authorizationChecker->isGranted('ROLE_ADMIN', $this->getUser())) {
            $mainTab
                ->add(
                    'enabled',
                    SwitchType::class,
                    [
                        'label' => 'admin.user.form.enabled.label',
                    ]
                )
                ->add(
                    'rawRoles',
                    RoleHierarchyType::class,
                    [
                        'label' => 'admin.user.form.roles.label',
                    ]
                )
                ->add(
                    'familyPermissions',
                    BootstrapCollectionType::class,
                    [
                        'label' => 'admin.user.form.familyPermissions.label',
                        'entry_type' => FamilyPermissionType::class,
                        'entry_options' => [],
                        'allow_add' => true,
                        'allow_delete' => true,
                        'required' => false,
                        'sortable' => false,
                        'by_reference' => false,
                    ]
                );

            $builder->add(
                '__tab_groups',
                TabType::class,
                [
                    'label' => 'admin.user.tab.groups.label',
                    'inherit_data' => true,
                ]
            );
            /** @var FormBuilderInterface $groupsTab */
            $groupsTab = $builder->get('__tab_groups');
            $groupsTab
                ->add(
                    'groups',
                    EntityType::class,
                    [
                        'label' => 'admin.user.form.groups.label',
                        'class' => Group::class,
                        'expanded' => true,
                        'multiple' => true,
                    ]
                );
        }

        $builder->add(
            '__tab_info',
            TabType::class,
            [
                'label' => 'admin.user.tab.info.label',
                'inherit_data' => true,
            ]
        );
        // Add EAV data edition
        $this->buildDataForm($builder);

        $builder->addEventListener(
            FormEvents::POST_SUBMIT,
            function (FormEvent $event) {
                /** @var User $user */
                $user = $event->getData();
                if ($user) {
                    $user->setUpdatedAt(new \DateTime());
                }
            }
        );
    }
959194
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        parent::buildForm($builder, $options);

        $this->addIban($builder)
            ->addBic($builder);
    }
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,
            ])
        ;
    }
701458
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        if($this->view == 'read_only'){
            $readOnly = true;
        } else {
            $readOnly = false;
        }

        $builder->add('name', 'text', array(
            'label' => 'Name',
//            'data' => $options['data']->getName(),
            'read_only' => $readOnly,
        ));

        if($this->view != 'hide_url'){
            $builder->add('URL', 'url', array(
                'label' => 'URL',
//                'data' => $options['data']->getUrl(),
                'read_only' => $readOnly,
            ));
        }

        if($this->view == 'checkbox'){
            $builder->add('selected', 'checkbox', array(
                'label'     => 'Add "'.$options['data']->getName().'" as location',
                'required'  => true,
                'data' => true,
                'mapped' => false,
                'attr' => array(
                    'align_with_widget' => true,
                ),
            ));
        }

        $hookListener = $this->getHookListener($builder);

        // Embed hook forms.
        $builder->addEventSubscriber($hookListener);
    }
376653
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->addModelTransformer($this)
            ->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($builder, $options) {
                $form = $event->getForm();
                $component = $event->getData();

                // Adds custom "data" component from component type
                $form->add('data', $component->getComponentType()->getFormType(), array_replace_recursive(
                    $options['variation']->getConfiguration(
                        'components',
                        $component->getComponentType()->getName(),
                        'config',
                        array()
                    ),
                    array(
                        'auto_initialize' => false,
                        'label' => false,
                    )
                ));
            })
        ;
    }
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\']);',
                    ],
            ]);
    }
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',
            ])
        ;
    }
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);
                    }
                }
            }
        );
    }
1210423
public function buildForm(FormBuilderInterface $builder, array $options)
	{
		$user_transformer = new StringToUserTransformer($this->userManager);
		$builder->addModelTransformer($user_transformer);
	}
1241367
public function buildForm (FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('name', 'text', array(
                'label' => 'Nom du groupe'
            ))
            ->add('roles', 'choice', array(
                'label' => 'Rôles',
                'choices' => $this->getRoles(),
                'multiple' => true,
                'expanded' => true
            ))
            ->add('users', 'olix_doublelist_entity', array(
                'label' => 'Utilisateurs',
                'class' => 'OlixSecurityBundle:User',
                'property' => 'name',
                'mapped' => false
            ))
        ;
    }
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;
        }
    }
1137900
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        if ($this->getParent() === 'hidden') {
            $builder->addModelTransformer($this->transformer);
        }
    }
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;
                }
            )
        );
    }
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());
                }
            }
        );
    }