src/Zicht/Bundle/AdminBundle/Controller/CRUDController.php
protected function bindAndRender($action)
    {
        // the key used to lookup the template
        $templateKey = 'edit';

        if ($action == 'edit') {
            $id = $this->getRequest()->get($this->admin->getIdParameter());

            $object = $this->admin->getObject($id);

            if (!$object) {
                throw new NotFoundHttpException(sprintf('unable to find the object with id : %s', $id));
            }

            if (false === $this->admin->isGranted('EDIT', $object)) {
                throw new AccessDeniedException();
            }
        } else {
            $object = $this->admin->getNewInstance();

            $this->admin->setSubject($object);

            /** @var $form \Symfony\Component\Form\Form */
            $form = $this->admin->getForm();
            $form->setData($object);
        }

        $this->admin->setSubject($object);

        /** @var $form \Symfony\Component\Form\Form */
        $form = $this->admin->getForm();
        $form->setData($object);

        if ($this->getRequest()->getMethod() == 'POST') {
            $form->handleRequest($this->getRequest());
        }

        $view = $form->createView();

        // set the theme for the current Admin Form
        $this->get('twig')->getRuntime(FormRenderer::class)->setTheme($view, $this->admin->getFormTheme());

        return $this->render(
            $this->admin->getTemplate($templateKey),
            array(
                'action' => $action,
                'form'   => $view,
                'object' => $object,
            )
        );
    }
protected function bindAndRender($action)
    {
        // the key used to lookup the template
        $templateKey = 'edit';

        if ($action == 'edit') {
            $id = $this->getRequest()->get($this->admin->getIdParameter());

            $object = $this->admin->getObject($id);

            if (!$object) {
                throw new NotFoundHttpException(sprintf('unable to find the object with id : %s', $id));
            }

            if (false === $this->admin->isGranted('EDIT', $object)) {
                throw new AccessDeniedException();
            }
        } else {
            $object = $this->admin->getNewInstance();

            $this->admin->setSubject($object);

            /** @var $form \Symfony\Component\Form\Form */
            $form = $this->admin->getForm();
            $form->setData($object);
        }

        $this->admin->setSubject($object);

        /** @var $form \Symfony\Component\Form\Form */
        $form = $this->admin->getForm();
        $form->setData($object);

        if ($this->getRequest()->getMethod() == 'POST') {
            $form->handleRequest($this->getRequest());
        }

        $view = $form->createView();

        // set the theme for the current Admin Form
        $this->get('twig')->getRuntime(FormRenderer::class)->setTheme($view, $this->admin->getFormTheme());

        return $this->render(
            $this->admin->getTemplate($templateKey),
            array(
                'action' => $action,
                'form'   => $view,
                'object' => $object,
            )
        );
    }
protected function bindAndRender ( $ action ) { // the key used to lookup the template $ templateKey = 'edit' ; if ( $ action == 'edit' ) { $ id = $ this -> getRequest ( ) -> get ( $ this -> admin -> getIdParameter ( ) ) ; $ object = $ this -> admin -> getObject ( $ id ) ; if ( ! $ object ) { throw new NotFoundHttpException ( sprintf ( 'unable to find the object with id : %s' , $ id ) ) ; } if ( false === $ this -> admin -> isGranted ( 'EDIT' , $ object ) ) { throw new AccessDeniedException ( ) ; } } else { $ object = $ this -> admin -> getNewInstance ( ) ; $ this -> admin -> setSubject ( $ object ) ; /** @var $form \Symfony\Component\Form\Form */ $ form = $ this -> admin -> getForm ( ) ; $ form -> setData ( $ object ) ; } $ this -> admin -> setSubject ( $ object ) ; /** @var $form \Symfony\Component\Form\Form */ $ form = $ this -> admin -> getForm ( ) ; $ form -> setData ( $ object ) ; if ( $ this -> getRequest ( ) -> getMethod ( ) == 'POST' ) { $ form -> handleRequest ( $ this -> getRequest ( ) ) ; } $ view = $ form -> createView ( ) ; // set the theme for the current Admin Form $ this -> get ( 'twig' ) -> getRuntime ( FormRenderer :: class ) -> setTheme ( $ view , $ this -> admin -> getFormTheme ( ) ) ; return $ this -> render ( $ this -> admin -> getTemplate ( $ templateKey ) , array ( 'action' => $ action , 'form' => $ view , 'object' => $ object , ) ) ; }
Binds the request to the form and only renders the resulting form.

@param string $action
@return \Symfony\Component\HttpFoundation\Response

@throws \Symfony\Component\Security\Core\Exception\AccessDeniedException
@throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
Binds the request to the form and only renders the resulting form .