if($saveAsId) // existed, updating { $res = Helper::update($saveAsId, $_REQUEST['element']); if($res['success']) // on successfull update ... { if($actionSave) $redirectUrl = $returnUrl ? $returnUrl : Helper::getListUrl(); // go to the page of just created item // $actionApply : do nothing } } else // new or copyed item { $res = Helper::add($_REQUEST['element']); if($res['success']) // on successfull add ... { if($actionSave) $redirectUrl = $returnUrl ? $returnUrl : Helper::getListUrl(); // go to the list page if($actionApply) $redirectUrl = $returnUrl ? $returnUrl : Helper::getEditUrl(array('id' => $res['id'])); // go to the page of just created item } } // no matter we updated or added a new item - we go to blank page on $actionSaveAndAdd if($res['success'] && $actionSaveAndAdd) $redirectUrl = Helper::getEditUrl(); // go to the blank page // on failure just show sad message