/** * Create new vial (of a stock) * * @Route("/new/{id}", defaults={"id" = null}) * @Template() * * @param mixed $id * @return \Symfony\Component\HttpFoundation\Response */ public function createAction($id = null) { $request = $this->getRequest(); if ($request->getMethod() != 'POST') { $class = $this->getEntityClass(); $vial = new $class(); if (null !== $id) { $stock = $this->getStockEntity($id); $vial->setStock($stock); } $data = array('vial' => $vial, 'number' => 1); $form = $this->createForm($this->getCreateForm(), $data); return array('form' => $form->createView()); } else { return parent::createAction(); } }