diff --git a/lib/dispatcher.inc.php b/lib/dispatcher.inc.php index 8956933..5962ad1 100644 --- a/lib/dispatcher.inc.php +++ b/lib/dispatcher.inc.php @@ -56,6 +56,10 @@ class KTDispatcher { } function redispatch($event_var, $action_prefix = null) { + $previous_event = KTUtil::arrayGet($_REQUEST, $this->event_var); + if ($previous_event) { + $this->persistParams(array($this->event_var)); + } $this->event_var = $event_var; if ($action_prefix) { $this->action_prefix = $action_prefix; @@ -212,12 +216,11 @@ class KTDispatcher { // handle the case where action is passed in already. } } - - // if it isn't already set - if ((!array_key_exists('action', $aQuery)) && (!empty($event))) { - $aQuery['action'] = urlencode($event); + if ((!array_key_exists($this->event_var, $aQuery)) && (!empty($event))) { + $aQuery[$this->event_var] = urlencode($event); } + var_dump($aQuery); if ($asArray) { return $aQuery; diff --git a/lib/widgets/forms.inc.php b/lib/widgets/forms.inc.php index a5b514c..6bb051e 100644 --- a/lib/widgets/forms.inc.php +++ b/lib/widgets/forms.inc.php @@ -21,6 +21,7 @@ class KTForm { var $_validators; // validators var $_submitlabel; // what is the "submit" button called var $_action; // where does the success message go + var $_event; // where does the success message go var $_extraargs; // various extra arguments var $_failaction; // should this error out, which action handles it var $_failurl; // if we don't have a failaction, try this url @@ -66,6 +67,15 @@ class KTForm { $this->_failurl = KTUtil::arrayGet($aOptions, 'fail_url'); $this->_submitlabel = KTUtil::arrayGet($aOptions, 'submit_label', _kt('Submit')); + + $this->_event = KTUtil::arrayGet($aOptions, 'event'); + if (empty($this->_event)) { + if (!is_null($context)) { + $this->_event = $context->event_var; + } else { + $this->_event = "action"; + } + } // cancel // there are a few options here: @@ -86,7 +96,7 @@ class KTForm { } else { // give it a try using addQSSelf $this->_cancelurl = KTUtil::addQueryStringSelf( - sprintf('action=%s', $cancel_action)); + sprintf('%s=%s', $this->_event, $cancel_action)); } @@ -275,7 +285,7 @@ class KTForm { // remove inner "action" var from extraargs // if its there at all. - unset($this->_extraargs['action']); + unset($this->_extraargs[$this->_event]); $this->_extraargs['_kt_form_name'] = $this->_kt_form_name; // now do the render. diff --git a/templates/ktcore/forms/outerform.smarty b/templates/ktcore/forms/outerform.smarty index 89ff839..0be3869 100644 --- a/templates/ktcore/forms/outerform.smarty +++ b/templates/ktcore/forms/outerform.smarty @@ -5,7 +5,7 @@ {if !empty($context->sDescription)}
{$context->sDescription}
{/if} {* hidden, "extra" args *} - + {foreach from=$context->_extraargs item=v key=k} {/foreach}