diff --git a/include/staff/helptopic.inc.php b/include/staff/helptopic.inc.php index cf43338fa5abf33fc15477418cc5d485d6a48653..7df72585c1efdc152630af9438bf53a09419106d 100644 --- a/include/staff/helptopic.inc.php +++ b/include/staff/helptopic.inc.php @@ -1,6 +1,6 @@ <?php if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access Denied'); -$info = $qs = array(); +$info = $qs = $forms = array(); if($topic && $_REQUEST['a']!='add') { $title=__('Update Help Topic'); $action='update'; @@ -17,8 +17,8 @@ if($topic && $_REQUEST['a']!='add') { $submit_text=__('Add Topic'); $info['isactive']=isset($info['isactive'])?$info['isactive']:1; $info['ispublic']=isset($info['ispublic'])?$info['ispublic']:1; - $info['form_id'] = Topic::FORM_USE_PARENT; $qs += array('a' => $_REQUEST['a']); + $forms = TicketForm::objects(); } $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); ?> @@ -387,21 +387,7 @@ foreach ($forms as $F) { <br/> <strong><?php echo __('Add Custom Form'); ?></strong>: - <select name="form_id" onchange="javascript: - event.preventDefault(); - var $this = $(this), - val = $this.val(); - if (!val) return; - $.ajax({ - url: 'ajax.php/form/' + val + '/fields/view', - dataType: 'json', - success: function(json) { - if (json.success) { - $(json.html).appendTo('#topic-forms').effect('highlight'); - $this.find(':selected').prop('disabled', true); - } - } - });"> + <select name="form_id" id="newform"> <option value=""><?php echo '— '.__('Add a custom form') . ' —'; ?></option> <?php foreach (DynamicForm::objects()->filter(array('type'=>'G')) as $F) { ?> <option value="<?php echo $F->get('id'); ?>" @@ -438,6 +424,23 @@ $(function() { }; $('[name=sequence_id]').on('change', update_example); $('[name=number_format]').on('keyup', update_example); + + $('form select#newform').change(function() { + var $this = $(this), + val = $this.val(); + if (!val) return; + $.ajax({ + url: 'ajax.php/form/' + val + '/fields/view', + dataType: 'json', + success: function(json) { + if (json.success) { + $(json.html).appendTo('#topic-forms').effect('highlight'); + $this.find(':selected').prop('disabled', true); + } + } + }); + }); + }); $('table#topic-forms').sortable({ items: 'tbody', diff --git a/scp/helptopics.php b/scp/helptopics.php index 01c01337b5f82a083dfd69089c01fc6d5d94fcae..adb1eb7c4fcc8c2830fd2b2e3e72b734a0a25d2b 100644 --- a/scp/helptopics.php +++ b/scp/helptopics.php @@ -36,8 +36,9 @@ if($_POST){ } break; case 'create': - $topic = Topic::create(); - if ($topic->update($_POST, $errors)) { + $_topic = Topic::create(); + if ($_topic->update($_POST, $errors)) { + $topic = $_topic; $msg=sprintf(__('Successfully added %s'), Format::htmlchars($_POST['topic'])); $_REQUEST['a']=null; }elseif(!$errors['err']){