/** * On a POST request, validate the user's input. If valid, save using the * RowEditor, set a success message and then redirect. Should also behave * reasonably well when used as an endpoint for an XHR by returning a success * message and the new primary key value. * * @param ResponseHelper $responseHelper */ public function process(ResponseHelper $responseHelper) { if ($this->request->isPost()) { $this->invalidSubmission = !$this->rowEditor->isValid($this->request->getPost()); if (!$this->invalidSubmission) { $title = strtolower($this->model->getSingularTitle()); if (!$this->request->isAjax()) { if ($this->isNew) { $responseHelper->setSuccessMessage("Successfully saved new {$title}."); } else { $responseHelper->setSuccessMessage("Successfully saved changes to {$title}."); } } $this->rowEditor->save(); if (!$this->request->isAjax()) { $this->redirect($responseHelper); } } } }
/** * Set the titles for this collection using the titles from a Table object. * * @param Table $table * @return $this */ public function setTitlesFromTable(Table $table) { $this->title = $table->getPluralTitle(); $this->singularTitle = $table->getSingularTitle(); $this->pluralTitle = $table->getPluralTitle(); return $this; }