diff --git a/include/ajax.forms.php b/include/ajax.forms.php index b6e5d2903b3ea7a7f41afbb3c666a3656a550e05..e199c23174bbf930ebe28606c13a1320e276c6cf 100644 --- a/include/ajax.forms.php +++ b/include/ajax.forms.php @@ -15,8 +15,7 @@ class DynamicFormsAjaxAPI extends AjaxController { function getFormsForHelpTopic($topic_id, $client=false) { $topic = Topic::lookup($topic_id); - if ($topic->ht['form_id'] - && ($form = DynamicForm::lookup($topic->ht['form_id']))) + if ($form = $topic->getForm()) $form->render(!$client); } diff --git a/include/class.topic.php b/include/class.topic.php index 930b1795dd0dbf2fc9143a58cc8699c2a64dd960..c415b157aa1e0cf063ae7d912cd2905b1e90dfd9 100644 --- a/include/class.topic.php +++ b/include/class.topic.php @@ -25,6 +25,8 @@ class Topic { const DISPLAY_DISABLED = 2; + const FORM_USE_PARENT = 4294967295; + function Topic($id) { $this->id=0; $this->load($id); @@ -128,8 +130,12 @@ class Topic { } function getForm() { - if(!$this->form && $this->getFormId()) - $this->form = DynamicForm::lookup($this->getFormId()); + $id = $this->getFormId(); + + if ($id == self::FORM_USE_PARENT && ($p = $this->getParent())) + $this->form = $p->getForm(); + elseif ($id && !$this->form) + $this->form = DynamicForm::lookup($id); return $this->form; } diff --git a/include/staff/helptopic.inc.php b/include/staff/helptopic.inc.php index 5e3396e2eb551d7a12f7fff032b694394551ccbe..00f06d38d0ca604b2adf81daa606132110fd7359 100644 --- a/include/staff/helptopic.inc.php +++ b/include/staff/helptopic.inc.php @@ -16,6 +16,7 @@ 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; $qstr.='&a='.$_REQUEST['a']; } $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); @@ -88,9 +89,14 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); <tr> <td><strong>Custom Form</strong>:</td> <td><select name="form_id"> - <option value="0">— No Extra Fields —</option> + <option value="0" <?php +if ($info['form_id'] == '0') echo 'selected="selected"'; + ?>>— None —</option> + <option value="<?php echo Topic::FORM_USE_PARENT; ?>" <?php +if ($info['form_id'] == Topic::FORM_USE_PARENT) echo 'selected="selected"'; + ?>>— Use Parent Form —</option> <?php foreach (DynamicForm::objects()->filter(array('type'=>'G')) as $group) { ?> - <option value="<?php echo $group->get('id'); ?>" + <option value="<?php echo $group->get('id'); ?>" <?php if ($group->get('id') == $info['form_id']) echo 'selected="selected"'; ?>> <?php echo $group->get('title'); ?>