コード例 #1
0
 /**
  * Creates a new apartment
  * @Route("/create", methods={"POST"}, name="createapartment")
  */
 public function createAction()
 {
     if (!$this->request->isPost()) {
         return $this->dispatcher->forward(array("controller" => "apartment", "action" => "index"));
     }
     $apartment = new Apartment();
     $apartment->setCompanyid($this->request->getPost("companyid"));
     $apartment->setTowerid($this->request->getPost("towerid"));
     $apartment->setName($this->request->getPost("name"));
     if (!$apartment->save()) {
         foreach ($apartment->getMessages() as $message) {
             $this->flash->error($message);
         }
         return $this->dispatcher->forward(array("controller" => "apartment", "action" => "new"));
     }
     $this->flash->success("apartment was created successfully");
     return $this->dispatcher->forward(array("controller" => "apartment", "action" => "index"));
 }