diff --git a/include/ajax.forms.php b/include/ajax.forms.php index e199c23174bbf930ebe28606c13a1320e276c6cf..9a026e83c5861f5621678dcf0864f008efd44e3a 100644 --- a/include/ajax.forms.php +++ b/include/ajax.forms.php @@ -14,9 +14,17 @@ class DynamicFormsAjaxAPI extends AjaxController { } function getFormsForHelpTopic($topic_id, $client=false) { - $topic = Topic::lookup($topic_id); + if (!($topic = Topic::lookup($topic_id))) + Http::response(404, 'No such help topic'); + + if ($_GET || isset($_SESSION[':form-data'])) { + if (!is_array($_SESSION[':form-data'])) + $_SESSION[':form-data'] = array(); + $_SESSION[':form-data'] = array_merge($_SESSION[':form-data'], $_GET); + } + if ($form = $topic->getForm()) - $form->render(!$client); + $form->getForm($_SESSION[':form-data'])->render(!$client); } function getClientFormsForHelpTopic($topic_id) { diff --git a/include/client/open.inc.php b/include/client/open.inc.php index 415eacabc5fda233296723eea60a538b67d88bbf..9cb1bb65739a4c3504ef701ae128378c943f91b0 100644 --- a/include/client/open.inc.php +++ b/include/client/open.inc.php @@ -33,8 +33,9 @@ if ($info['topicId'] && ($topic=Topic::lookup($info['topicId']))) { <td class="required">Help Topic:</td> <td> <select id="topicId" name="topicId" onchange="javascript: + var data = $(':input[name]', '#dynamic-form').serialize(); $('#dynamic-form').load( - 'ajax.php/form/help-topic/' + this.value); + 'ajax.php/form/help-topic/' + this.value, data); "> <option value="" selected="selected">— Select a Help Topic —</option> <?php diff --git a/include/staff/ticket-open.inc.php b/include/staff/ticket-open.inc.php index f9a3ad3c161ab14730b4814ae1ae93433e9150bb..bfd0571bdbc0ffb660831a54f2c463ba095e43b7 100644 --- a/include/staff/ticket-open.inc.php +++ b/include/staff/ticket-open.inc.php @@ -127,8 +127,9 @@ if ($info['topicId'] && ($topic=Topic::lookup($info['topicId']))) { </td> <td> <select name="topicId" onchange="javascript: + var data = $(':input[name]', '#dynamic-form').serialize(); $('#dynamic-form').load( - 'ajax.php/form/help-topic/' + this.value); + 'ajax.php/form/help-topic/' + this.value, data); "> <?php if ($topics=Topic::getHelpTopics()) { diff --git a/open.php b/open.php index e0bc8fdcfb1ba75a1efca191e0a31cc06ac36930..fe454521b8b6561f616a125d0ee3b699239ebcc0 100644 --- a/open.php +++ b/open.php @@ -38,6 +38,8 @@ if ($_POST) { //Ticket::create...checks for errors.. if(($ticket=Ticket::create($vars, $errors, SOURCE))){ $msg='Support ticket request created'; + // Drop session-backed form data + unset($_SESSION[':form-data']); //Logged in...simply view the newly created ticket. if($thisclient && $thisclient->isValid()) { session_write_close(); diff --git a/scp/tickets.php b/scp/tickets.php index 82f0e569fd6926ba949f1d41aa6458e3c647e170..16b9d4cde3518968d6fe70a1b345c83c539d5d37 100644 --- a/scp/tickets.php +++ b/scp/tickets.php @@ -497,6 +497,7 @@ if($_POST && !$errors): if (!$ticket->checkStaffAccess($thisstaff) || $ticket->isClosed()) $ticket=null; Draft::deleteForNamespace('ticket.staff%', $thisstaff->getId()); + unset($_SESSION[':form-data']); } elseif(!$errors['err']) { $errors['err']='Unable to create the ticket. Correct the error(s) and try again'; }