public function editAction() { $this->view->setRenderLevel(Phalcon\Mvc\View::LEVEL_ACTION_VIEW); $id = $this->getParam('id'); $row = $this->getTable()->findFirst($id); $this->view->rowsCategory = Category_Dish_Table::getInstance()->find(); $this->view->rowsPlace = Place_Table::getInstance()->find(); $this->view->weightUnits = (new Dish_Unit_Enum())->getAll(); $this->view->row = $row; if (!$this->request->isPost()) { return; } $this->view->disable(); // Получение переменных методом POST $name = $this->getPost('name'); $placeId = $this->getPost('place_id'); $categoryId = $this->getPost('category_id'); $picture = $this->getPost('picture'); $price = $this->getPost('price'); $weight = $this->getPost('weight'); $weightUnit = $this->getPost('weight_unit'); $description = $this->getPost('description'); $row->name($name)->placeId($placeId)->categoryId($categoryId)->picture($picture)->price($price)->weight($weight)->weightUnit($weightUnit)->description($description)->save(); echo json_encode($row->toArray()); }
public function deleteAction() { $this->view->disable(); $id = $this->getParam('id'); $row = Category_Dish_Table::getInstance()->find($id); $row->delete(); }