public function save() { $data = $this->post(); if ($data['pID']) { $this->edit($data['pID']); } else { $this->add(); } if ($this->isPost()) { $errors = $this->validate($data); $this->error = null; //clear errors $this->error = $errors; if (!$errors->has()) { $product = VividProduct::save($data); $aks = StoreProductKey::getList(); foreach ($aks as $uak) { $uak->saveAttributeForm($product); } if ($data['pID']) { $this->redirect('/dashboard/store/products/', 'updated'); } else { $this->redirect('/dashboard/store/products/', 'success'); } } //if no errors } //if post }