public function editAction() { $this->userService->checkRightGate('CONTENT_EDIT'); $form = $this->formManager->initForm('catEditForm', dirname(__FILE__) . '/categoryForm.xml'); if ($form->isSubmit()) { if ($form->isValid()) { $cat = $form->getContainer('category'); $this->categoryService->save($cat); $this->forward('content', 'category', 'index', array('idCat' => $cat->id)); return; } } else { $id = $this->getParam('idCat', 0); if ($id == '') { $this->goHome(); return; } $cat = $this->categoryService->get($id); if ($cat == null) { $this->goHome(); return; } $form->setContainer('category', $cat); } $this->formManager->storeForm($form); $this->assign('form', $form); $this->assign('category', $cat); }
<tr> <td style="height:26px" > <input type="submit" id="btnSave" name="btnSave" class="submit_btn" onsubmit="return save()" value="Save"/> </td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </form> </div> </body> </html> <?php if (isset($_POST['btnSave'])) { $service = new CategoryService(); $sql = ' insert into category '; $title = $_POST["txtEditTitle"]; $dataArray = array("category_title" => "'" . $title . "'"); $sql .= $service->GetInsertSQL($dataArray); $id = $service->save($sql); if ($id != 0) { alertRedirect(true, 'DisplayCategory.php'); } else { alertRedirect(false, 'DisplayCategory.php'); } }