Use explicit set save toolbar actions
This commit is contained in:
@@ -38,6 +38,42 @@ class SetController extends FormController
|
||||
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');
|
||||
|
||||
Reference in New Issue
Block a user