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);
        }
    }
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);
        }
    }
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 ) ; } }
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
Adds a CSRF field to the root form view .