public function formAction(StructureInterface $structure, $preview = false, $partial = false)
    {
        /** @var Request $request */
        $request = $this->get('request_stack')->getCurrentRequest();

        // get attributes
        $attributes = $this->getAttributes([], $structure, $preview);

        $template = $structure->getKey();

        $typeClass = $this->getTypeClass($template);
        /** @var AbstractType $type */
        $type = $this->get('form.registry')->getType($typeClass)->getInnerType();
        $type->setAttributes($attributes);

        $this->form = $this->get('form.factory')->create($typeClass);
        $this->form->handleRequest($request);

        if ($this->form->isSubmitted()
            && $this->form->isValid()
            && $response = $this->handleFormSubmit($request, $type, $attributes)
        ) {
            // success form submit

            return $response;
        }

        return parent::indexAction($structure, $preview, $partial);
    }
public function formAction(StructureInterface $structure, $preview = false, $partial = false)
    {
        /** @var Request $request */
        $request = $this->get('request_stack')->getCurrentRequest();

        // get attributes
        $attributes = $this->getAttributes([], $structure, $preview);

        $template = $structure->getKey();

        $typeClass = $this->getTypeClass($template);
        /** @var AbstractType $type */
        $type = $this->get('form.registry')->getType($typeClass)->getInnerType();
        $type->setAttributes($attributes);

        $this->form = $this->get('form.factory')->create($typeClass);
        $this->form->handleRequest($request);

        if ($this->form->isSubmitted()
            && $this->form->isValid()
            && $response = $this->handleFormSubmit($request, $type, $attributes)
        ) {
            // success form submit

            return $response;
        }

        return parent::indexAction($structure, $preview, $partial);
    }
public function formAction ( StructureInterface $ structure , $ preview = false , $ partial = false ) { /** @var Request $request */ $ request = $ this -> get ( 'request_stack' ) -> getCurrentRequest ( ) ; // get attributes $ attributes = $ this -> getAttributes ( [ ] , $ structure , $ preview ) ; $ template = $ structure -> getKey ( ) ; $ typeClass = $ this -> getTypeClass ( $ template ) ; /** @var AbstractType $type */ $ type = $ this -> get ( 'form.registry' ) -> getType ( $ typeClass ) -> getInnerType ( ) ; $ type -> setAttributes ( $ attributes ) ; $ this -> form = $ this -> get ( 'form.factory' ) -> create ( $ typeClass ) ; $ this -> form -> handleRequest ( $ request ) ; if ( $ this -> form -> isSubmitted ( ) && $ this -> form -> isValid ( ) && $ response = $ this -> handleFormSubmit ( $ request , $ type , $ attributes ) ) { // success form submit return $ response ; } return parent :: indexAction ( $ structure , $ preview , $ partial ) ; }
Form action.

@param StructureInterface $structure
@param bool $preview
@param bool $partial

@return JsonResponse|RedirectResponse|Response
Form action .