/** * Creates a new companie */ public function createAction() { if (!$this->request->isPost()) { return $this->dispatcher->forward(array("controller" => "companies", "action" => "index")); } $companie = new Companies(); $companie->id = $this->request->getPost("id"); $companie->name = $this->request->getPost("name"); if (!$companie->save()) { foreach ($companie->getMessages() as $message) { $this->flash->error($message); } return $this->dispatcher->forward(array("controller" => "companies", "action" => "new")); } $this->flash->success("companie was created successfully"); return $this->dispatcher->forward(array("controller" => "companies", "action" => "index")); }
public function createAction() { if (!$this->request->isPost()) { return $this->forward("companies/index"); } $companies = new Companies(); $companies->name = $this->request->getPost("name", "striptags"); $companies->telephone = $this->request->getPost("telephone", "striptags"); $companies->address = $this->request->getPost("address", "striptags"); $companies->city = $this->request->getPost("city", "striptags"); if (!$companies->save()) { foreach ($companies->getMessages() as $message) { $this->flash->error((string) $message); } return $this->forward("companies/new"); } $this->flash->success("Company was created successfully"); return $this->forward("companies/index"); }
public function createAction() { if (!$this->request->isPost()) { return $this->_forward("companies/index"); } $companies = new Companies(); $companies->id = $this->request->getPost("id", "int"); $companies->name = $this->request->getPost("name"); $companies->telephone = $this->request->getPost("telephone"); $companies->address = $this->request->getPost("address"); $companies->city = $this->request->getPost("city"); $companies->name = strip_tags($companies->name); $companies->telephone = strip_tags($companies->telephone); $companies->address = strip_tags($companies->address); $companies->city = strip_tags($companies->city); if (!$companies->save()) { foreach ($companies->getMessages() as $message) { Flash::error((string) $message, "alert alert-error"); } return $this->_forward("companies/new"); } else { Flash::success("companies was created successfully", "alert alert-success"); return $this->_forward("companies/index"); } }