コード例 #1
0
 /**
  * Displays a form to create an entity entry.
  *
  * @param $bundle
  * @param Request $request
  * @param $entity
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function newAction($bundle, Request $request, $entity)
 {
     $ah = $this->get('itf.admin_helper');
     $ah->setBundle($bundle);
     $ah->setEntity($entity);
     $entity_config = $this->get('itf.admin.config')->getEntityConfig();
     // setup response
     $response = ControllerResponse::create($this)->setBundle($bundle)->setEntityName($entity)->setTemplate('ITFAdminBundle:Admin:new.html.twig');
     // set request data
     $entity = new \ITF\AdminBundle\Admin\Entity($entity, $this);
     $entity->setRequestData($request);
     // get form
     $form = $this->createActionForm($entity, 'add');
     $response->setForm($form->createView());
     // if template set
     if (isset($entity_config['template']['new']) && $entity_config['template']['new'] !== false) {
         $response->setTemplate($entity_config['template']['new']);
     }
     return $response->createResponse();
 }