input->getInt('parent_id'); $this->setRedirect('index.php?option=com_testquestions&view=set&layout=edit&parent_id=' . $parentId); } public function save2close($key = null, $urlVar = null) { $formData = (array) $this->input->post->get('jform', [], 'array'); $parentId = (int) ($formData['parent_id'] ?? 0); $itemId = (int) ($formData['id'] ?? $this->input->getInt('id')); $result = parent::save2close($key, $urlVar); if ($result) { if ($itemId > 0) { $item = $this->getModel()->getItem($itemId); $parentId = (int) ($item->parent_id ?? $parentId); } if ($parentId > 0) { $this->setRedirect('index.php?option=com_testquestions&task=set.edit&id=' . $parentId); } } return $result; } public function save($key = null, $urlVar = null) { $formData = (array) $this->input->post->get('jform', [], 'array'); $result = parent::save($key, $urlVar); $itemId = (int) ($formData['id'] ?? $this->input->getInt('id')); if ($result && $itemId > 0) { $this->setRedirect('index.php?option=com_testquestions&task=set.edit&id=' . $itemId); } return $result; } public function saveandclose($key = null, $urlVar = null) { $formData = (array) $this->input->post->get('jform', [], 'array'); $parentId = (int) ($formData['parent_id'] ?? 0); $result = parent::save($key, $urlVar); $itemId = (int) ($formData['id'] ?? $this->input->getInt('id')); if ($result && $itemId > 0 && $parentId < 1) { $item = $this->getModel()->getItem($itemId); $parentId = (int) ($item->parent_id ?? 0); } if ($result) { $this->setRedirect( $parentId > 0 ? 'index.php?option=com_testquestions&task=set.edit&id=' . $parentId : 'index.php?option=com_testquestions&view=sets' ); } return $result; } public function cancel($key = null) { $parentId = $this->input->getInt('parent_id'); $formData = (array) $this->input->post->get('jform', [], 'array'); $parentId = (int) ($formData['parent_id'] ?? $parentId); if ($parentId < 1) { $itemId = $this->input->getInt('id'); if ($itemId > 0) { $item = $this->getModel()->getItem($itemId); $parentId = (int) ($item->parent_id ?? 0); } } if ($parentId > 0) { $this->setRedirect('index.php?option=com_testquestions&task=set.edit&id=' . $parentId); return true; } $this->setRedirect('index.php?option=com_testquestions&view=sets'); return true; } }