public function edit($id = 0, $objectID = 0) { $this->set('category', $this->CategoryProduct->findById($objectID)); if ($this->request->is('post') || $this->request->is('put')) { if ($id) { $this->request->data('PMFormField.id', $id); } else { $this->request->data('PMFormField.object_type', 'CategoryParam'); $this->request->data('PMFormField.object_id', $objectID); } if ($this->PMFormField->save($this->request->data)) { $id = $this->PMFormField->id; if ($this->request->is('post')) { $this->PMFormKey->save(array('form_id' => 1, 'field_id' => $id)); } $baseRoute = array('action' => 'index', $objectID); return $this->redirect($this->request->data('apply') ? $baseRoute : array($id, $objectID)); } } elseif ($id) { $field = $this->PMFormField->findById($id); $this->request->data = $field; } if (!$id) { $this->request->data('PMFormField.sort_order', '1'); } $this->set('aFieldTypes', FieldTypes::getTypes()); $this->set('PMFormField__SELECT', FieldTypes::SELECT); $this->set('PMFormField__MULTISELECT', FieldTypes::MULTISELECT); $this->set('PMFormField__FORMULA', FieldTypes::FORMULA); }
public function beforeRender() { parent::beforeRender(); // $this->set('objectType', 'Param'); $this->set('aFieldTypes', FieldTypes::getTypes()); $category = $this->Category->findById($this->parentArticle['ParamGroup']['parent_id']); $this->set('category', $category); }