public function updatePage($id, $input) { $input = array_only($input, static::$PageFields); $page = $this->Page->findOrFail($id); $this->validator = $this->Validator->make($input, $this->Page->updateRules, $this->Page->messages); if ($this->validator->passes()) { $page->update($input); $this->cacheDeviseRoutes(); return $page; } $this->errors = $this->validator->errors()->all(); $this->message = "There were validation errors."; return false; }
/** * Request page be updated with given input * * @param integer $id * @param array $input * @return Redirector */ public function requestUpdatePage($id, $input) { $page = $this->PageManager->updatePage($id, $input); if ($page) { return $this->Redirect->route('dvs-pages')->with('warnings', $this->PageManager->warnings)->with('message', $this->PageManager->message); } return $this->Redirect->route('dvs-pages-edit', $id)->withInput()->withErrors($this->PageManager->errors)->with('message', $this->PageManager->message); }