public function edit($id = null) { $this->request->allowMethod(['put']); $employee = $this->Employees->get($id); $employee = $this->Employees->patchEntity($employee, $this->request->getData()); if ($this->Employees->save($employee)) { $message = 'Saved'; } else { $message = 'Error'; } $this->set([ 'message' => $message, 'employee' => $employee, ]); $this->viewBuilder()->setOption('serialize', ['employee', 'message']); }