Adds a CSRF field to the root form view.

@param FormView      $view    The form view
@param FormInterface $form    The form
@param array         $options The options
962406
public function finishView(FormView $view, FormInterface $form, array $options)
    {
        if ($options['csrf_protection'] && !$view->parent && $options['compound']) {
            $factory = $form->getConfig()->getFormFactory();
            $tokenId = $options['csrf_token_id'] ?: ($form->getName() ?: \get_class($form->getConfig()->getType()->getInnerType()));
            $data = (string) $options['csrf_token_manager']->getToken($tokenId);

            $csrfForm = $factory->createNamed($options['csrf_field_name'], 'Symfony\Component\Form\Extension\Core\Type\HiddenType', $data, [
                'block_prefix' => 'csrf_token',
                'mapped' => false,
            ]);

            $view->children[$options['csrf_field_name']] = $csrfForm->createView($view);
        }
    }
1063486
public function getFormFieldZone(FormView $formView)
    {
        $zones = $this->getZoneNames();

        /** @var LayoutBlockInterface $layoutBlock */
        if ($layoutBlock = $formView->vars['value']) {
            if ($zone = $layoutBlock->getZone()) {
                if (in_array($zone, $zones)) {
                    return $zone;
                }
            }
        }

        return current($zones);
    }
138183
public function render(Zend_View_Interface $view = null)
	{
        $formTypes = array( // avaible form types of Twitter Bootstrap form (i.e. classes)
          'horizontal',
          'inline',
          'vertical',
          'search'
        );
        
        $set = false;
        
        foreach($formTypes as $type) {
            if($this->getAttrib($type)) {
                $this->addDecorator("Form", array("class" => "form-$type"));
                $set = true;
            } 
        }
        if(true !== $set) { // if neither type was set, we set the default vertical class
            $this->addDecorator("Form", array("class" => "form-vertical"));
        }

		return parent::render($view);
	}
293378
public function renderFormJavascriptPrototypes(array $context, FormView $rootView)
    {
        if (!isset($rootView->vars['prototype'])) {
            throw new \InvalidArgumentException('The given root form view has no prototype');
        }

        $stack = [
            // FormView $prototype, string $prototypeName, string[] $parentPrototypeNames
            [$rootView->vars['prototype'], $rootView->vars['prototype']->vars['name'], []],
        ];

        $output = '[';
        $counter = 0;

        while (list($prototype, $prototypeName, $parentPrototypeNames) = \array_pop($stack)) {
            try {
                // the "unique_block_prefix" must be changed to prevent messing
                // up FormRenderer's internal cache and causing errors later on
                $prototype->vars['unique_block_prefix'] .= \sprintf('_%d', ++$this->prototypeRenderUidSeq);

                if (isset($prototype->vars['prototype'])) {
                    // directly nested collection prototypes lead to recursion in searchAndRenderBlock()
                    throw new \RuntimeException('Directly nested collections with prototypes are not supported. Add an intermediate type or disable prototypes.');
                }
                $code = $this->renderer->searchAndRenderBlock($prototype, 'javascript_prototype', $context);

                if (++$counter > 1) {
                    $output .= ",\n";
                }

                $output .= \sprintf(
                    '{id: %s, prototypeName: %s, parentPrototypeNames: %s, initializer: function ($field) { %s }}',
                    \json_encode($prototype->vars['id']),
                    \json_encode($prototypeName),
                    \json_encode($parentPrototypeNames),
                    $code
                );
            } catch (\LogicException $e) {
                foreach ($prototype->children as $child) {
                    $stack[] = isset($child->vars['prototype'])
                        ? [
                            $child->vars['prototype'],
                            $child->vars['prototype']->vars['name'],
                            \array_merge($parentPrototypeNames, [$prototypeName]),
                        ]
                        : [
                            $child,
                            $prototypeName,
                            $parentPrototypeNames,
                        ];
                }
            }
        }

        $output .= ']';

        return $output;
    }
635180
protected function createBlockView(FormView $view)
    {
        $bView = new BlockView();
        $bView->vars = $view->vars;
        $bView->vars['block'] = $bView;
        unset($bView->vars['form']);

        return $bView;
    }
907043
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($builder, $options) {
                if (empty($options['templates'])) {
                    return;
                }
                $event->getForm()->add('_template', ChoiceType::class, array(
                    'required' => true,
                    'choices' => $options['templates'],
                ));
            })
        ;
    }
895384
private function addContentFieldset(FormInterface $form)
    {
        $contentData = $form->addChild($this->getElement('nested_fieldset', [
            'name'  => 'content_data',
            'label' => 'common.fieldset.description',
        ]));
        
        $languageData = $contentData->addChild($this->getElement('language_fieldset', [
            'name'        => 'translations',
            'label'       => 'common.fieldset.translations',
            'transformer' => $this->getRepositoryTransformer('translation', $this->get('page.repository')),
        ]));
        
        $languageData->addChild($this->getElement('rich_text_editor', [
            'name'  => 'content',
            'label' => 'common.label.description',
        ]));
    }
1365898
protected function createCommandFromData(FormInterface $form, Options $options)
    {
        $reflection = new ReflectionClass($this->getCommandClass());
        $data = [];
        /** @var FormInterface $field */
        foreach ($form as $field) {
            $data[$field->getName()] = $field->getData();
        }

        return $reflection->newInstanceArgs($data);
    }
1321611
private function setFormTheme(FormView $formView, $theme)
    {
        $twig = $this->get('twig');

        // BC for Symfony < 3.2 where this runtime does not exists
        if (!method_exists('Symfony\Bridge\Twig\AppVariable', 'getToken')) {
            $twig->getExtension('Symfony\Bridge\Twig\Extension\FormExtension')
                ->renderer->setTheme($formView, $theme);

            return;
        }

        // BC for Symfony < 3.4 where runtime should be TwigRenderer
        if (!method_exists('Symfony\Bridge\Twig\Command\DebugCommand', 'getLoaderPaths')) {
            $twig->getRuntime('Symfony\Bridge\Twig\Form\TwigRenderer')->setTheme($formView, $theme);

            return;
        }

        $twig->getRuntime('Symfony\Component\Form\FormRenderer')->setTheme($formView, $theme);
    }
740274
public function finishView(FormView $view, FormInterface $form, array $options)
    {
        $data = $this->context->getCurrentNodeId();

        if (!$view->parent && $options['compound'] and !empty($data)) {
            $factory = $form->getConfig()->getFormFactory();

            $form = $factory->createNamed($options['node_id_field_name'], 'hidden', $data, ['mapped' => false]);

            $view->children[$options['node_id_field_name']] = $form->createView($view);
        }
    }
920016
public static function validate(FormInterface $form)
    {
        $groups = array('CsrProfile');

        $groups[] = self::password($form);

        return array_filter(
            array_unique($groups)
        );
    }
992247
public function buildView(FormView $view, FormInterface $form, array $options)
    {   
        $data = $form->getData();
        $view->vars['configs'] = array_merge(array(
            'dependent_value' => isset($data[$options['second_name']]) ? $data[$options['second_name']] : null
        ), $options['configs']);
        
    }
787948
public function render(?string $formId = null, ?string $view = null) : ?string
    {
        if (!$this->enabled()) {
            return null;
        }

        $useView = $view !== null ? $view : $this->view;

        if ($this->viewFactory->exists($useView)) {
            return $this->viewFactory->make($useView, $this->getViewData($formId))->render();
        }

        throw new FileNotFoundException("View '{$useView}' not found");
    }
1210532
public function createFormView(FormInterface $form)
    {
        $post = $this->eavManager->initializeEntity($form->getSchema());

        $form = $this->formFactory->create(PostType::class, $post, ['form_id' => $form->getId()]);

        return $form->createView();
    }
189203
private function addFieldConstraintOptions(array &$options, array $formFieldConfiguration)
    {
        if ($options['required'] === true) {
            $options['constraints'][] = new NotBlank();
        }

        if (isset($formFieldConfiguration['validators'])) {
            $options['constraints'] = array();
            foreach ($formFieldConfiguration['validators'] as $validatorClass => $validatorOptions) {
                $options['constraints'][] = new $validatorClass($validatorOptions);
            }
        }
    }
1342419
public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $builder
            ->add(
                self::START_NAME,
                DateType::class,
                [
                    'widget' => 'single_text',
                    'attr' => [
                        'placeholder' => 'sidus.filter.date_range.start_date',
                    ],
                ]
            )
            ->add(
                self::END_NAME,
                DateType::class,
                [
                    'widget' => 'single_text',
                    'attr' => [
                        'placeholder' => 'sidus.filter.date_range.end_date',
                    ],
                ]
            );
    }
1032594
private function createLabelPrefix(FormView $view, FormInterface $form, $depth = 1)
    {
        if (($labelPrefix = $form->getConfig()->getOption('label_prefix')) === null) {
            return $this->createParentLabelPrefix($view, $form, $depth);
        }

        if ($depth === 1 && ($rootLabelPrefix = $this->createParentLabelPrefix($view, $form, $depth)) !== null) {
            return $rootLabelPrefix;
        }

        return $labelPrefix;
    }