function update($id) { $this->respondTo('html', function () use($id) { $response = $this->getResponse(); $request = $this->getRequest(); try { Author::update($id, $this->getRequest()->getParams()); $response->redirect('App\\Admin\\Controllers\\AuthorController', 'index'); } catch (ValidationException $e) { $flash = $this->getSession()->getFlashBag(); $flash->set('errors', $e->getErrors()); $flash->set('inputs', $request->getParams()->all()); $response->redirect('App\\Admin\\Controllers\\AuthorController', 'edit', [$id]); } }); }