Builds the embedded form representing the user.

@param FormBuilderInterface $builder
@param array                $options
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')
                          ));
    }
784596
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        parent::buildForm($builder, $options);
        $builder->get('value')->addModelTransformer(new StringToBooleanTransformer('1'));
    }
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()]);
    }
846973
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        parent::buildForm($builder, $options);
        $form_options = $builder->get('value')->getOptions();
        if ($form_options['multiple']) {
            $builder->get('value')->addModelTransformer(new StringToArrayTransformer(','));
        }
    }
1050186
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $tags = $this->filterQueryHandler->handle($options['widget'], Tag::class);

        foreach ($tags as $tag) {
            $tagsChoices[$tag->getTitle()] = $tag->getId();
        }

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

        $builder
            ->add('tags', ChoiceType::class, [
                'label'             => false,
                'choices'           => $tagsChoices,
                'choices_as_values' => true,
                'placeholder'       => 'blog.tag_filter.empty_value',
                'required'          => false,
                'expanded'          => true,
                'multiple'          => $options['multiple'],
                'data'              => $data,
            ]);
    }
1226459
public function buildForm(FormBuilderInterface $builder, array $options)
    {

        $configValue = $options['data'];
        $formOptions = array();
        if ( $configValue->getConfigType()->getOptions()
            && $typeOptions = json_decode($configValue->getConfigType()->getOptions())
        ) {
            $typeOptions = $this->_recursiveGetObjectVars($typeOptions);
            $formOptions = array_merge($formOptions, $typeOptions);
        }
        if ( $configValue->getOptions()
            && $valueOptions = json_decode($configValue->getOptions())
        ) {
            $valueOptions = $this->_recursiveGetObjectVars($valueOptions);
            $formOptions = array_merge($formOptions, $valueOptions);
        }
        $defaultFormOptions = array(
            'label' => $this->container->get('translator')->trans($configValue->getVLabel(), array(), 'VinceTAdminConfigurationBundle'),
            'label_attr' => array(
                'class' => 'control-label'
            ),
            'required' => false,
        );
        $formOptions = array_merge($formOptions, $defaultFormOptions);

        $dispatcher = $this->container->get('event_dispatcher');

        $event = new AdminConfigurationFormCreateOptionsEvent($configValue->getPath(), $formOptions);
        $dispatcher->dispatch(AdminConfigurationEvents::ADMIN_CONFIGURATION_FORM_OPTIONS_CREATE, $event);

        $formOptions = $event->getFormOptions();

        $builder
            ->add(
                'value',
                $configValue->getConfigType()->getFormType(),
                $formOptions
            );
    }
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);
    }
174767
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        parent::buildForm($builder, $options);

        $this->addBankGroupType($builder, $options);
    }
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,
            ])
        ;
    }
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(),
                        ))),
                    ),
                ));
            })
        ;
    }
1196975
public function buildForm(FormBuilderInterface $builder, array $options) {
        /** @var ClassAwareDataTransformerInterface $entityTransformer */
        $entityTransformer = new $options['transformer']($this->om, $options['class']);
        $builder->addModelTransformer($entityTransformer);
    }
465677
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $this->dataTransformer->setReferenceClass($options['reference_class']);
        $this->dataTransformer->setInversedClass($options['inversed_class']);
        $this->dataTransformer->setInversedProperty($options['inversed_property']);
        
        $builder->addModelTransformer($this->dataTransformer);
    }
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);
        }
    }
730514
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->addModelTransformer(new CallbackTransformer(
            function ($original) {
                $ids = json_decode($original);

                $items = $this->contentManager->getRepository()
                    ->createQueryBuilder('c')
                    ->where('c.id IN (:ids)')
                    ->setParameter('ids', $ids)
                    ->getQuery()
                    ->getResult();

                return $items;
            },
            function ($submitted) {
                if (!$submitted instanceof ArrayCollection && !is_array($submitted)) {
                    return null;
                }

                $ids = [];
                foreach ($submitted as $content) {
                    $ids[] = $content->getId();
                }

                return json_encode($ids);
            }
        ));
    }
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);
        }
    }
284392
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        if ($options['businessEntityId'] !== null) {
            if ($options['namespace'] === null) {
                throw new \Exception('The namespace is mandatory if the business_entity_id is given.');
            }
            if ($options['mode'] === null) {
                throw new \Exception('The mode is mandatory if the business_entity_id is given.');
            }
        }

        if ($options['mode'] === Widget::MODE_ENTITY) {
            $this->addEntityFields($builder, $options);
        }

        if ($options['mode'] === Widget::MODE_QUERY) {
            $this->addQueryFields($builder, $options);
        }

        if ($options['mode'] === Widget::MODE_BUSINESS_ENTITY) {
            $this->addBusinessEntityFields($builder, $options);
        }

        //add the mode to the form
        $builder->add('mode', HiddenType::class, [
            'data' => $options['mode'],
        ]);
        $builder->add('asynchronous', HiddenType::class);
        $builder->add('theme', HiddenType::class);
        $builder->add('quantum', QuantumType::class, [
            'label' => 'victoire.widget.type.quantum.label',
            'attr'  => [
                'data-flag' => 'v-quantum-name',
            ],
        ]);

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

        $this->addCriteriasFields($builder, $options);
        //we use the PRE_SUBMIT event to set the mode option
        $builder->addEventListener(
            FormEvents::PRE_SUBMIT,
            function (FormEvent $event) use ($options) {
                //we get the raw data for the widget form
                $rawData = $event->getData();

                //get the posted mode
                $mode = $rawData['mode'];

                //get the form to add more fields
                $form = $event->getForm();

                //the controller does not use the mode to construct the form, so we update it automatically
                if ($mode === Widget::MODE_ENTITY) {
                    $this->addEntityFields($form, $options);
                }

                if ($mode === Widget::MODE_QUERY) {
                    $this->addQueryFields($form, $options);
                }
                if ($mode === Widget::MODE_BUSINESS_ENTITY) {
                    $this->addBusinessEntityFields($form, $options);
                }
            }
        );
    }