Skip to content
Snippets Groups Projects
Commit 51abf377 authored by Peter Rotich's avatar Peter Rotich
Browse files

bugs: Fix help topic create + forms

parent 7df3fced
No related branches found
No related tags found
No related merge requests found
<?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',
......
......@@ -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']){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment