From dfc8c63e2746a0c7a88b6a3e99da9947128c3c04 Mon Sep 17 00:00:00 2001 From: Peter Rotich <peter@enhancesoft.com> Date: Wed, 7 Nov 2018 16:21:47 +0000 Subject: [PATCH] Field: Help Topic Forms Don't show fields disabled by help topic Pass create mode for pre-selected help topic forms --- include/client/open.inc.php | 4 +++- include/client/templates/dynamic-form.tmpl.php | 8 ++++++++ include/staff/ticket-open.inc.php | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/include/client/open.inc.php b/include/client/open.inc.php index 021de566a..d0a96effc 100644 --- a/include/client/open.inc.php +++ b/include/client/open.inc.php @@ -89,7 +89,9 @@ if ($info['topicId'] && ($topic=Topic::lookup($info['topicId']))) { </tr> </tbody> <tbody id="dynamic-form"> - <?php foreach ($forms as $form) { + <?php + $options = array('mode' => 'create'); + foreach ($forms as $form) { include(CLIENTINC_DIR . 'templates/dynamic-form.tmpl.php'); } ?> </tbody> diff --git a/include/client/templates/dynamic-form.tmpl.php b/include/client/templates/dynamic-form.tmpl.php index e7e017a59..f668f4320 100644 --- a/include/client/templates/dynamic-form.tmpl.php +++ b/include/client/templates/dynamic-form.tmpl.php @@ -16,6 +16,14 @@ $isCreate = (isset($options['mode']) && $options['mode'] == 'create'); // Form fields, each with corresponding errors follows. Fields marked // 'private' are not included in the output for clients foreach ($form->getFields() as $field) { + try { + if (!$field->isEnabled()) + continue; + } + catch (Exception $e) { + // Not connected to a DynamicFormField + } + if ($isCreate) { if (!$field->isVisibleToUsers() && !$field->isRequiredForUsers()) continue; diff --git a/include/staff/ticket-open.inc.php b/include/staff/ticket-open.inc.php index 09bcfb21f..267d92765 100644 --- a/include/staff/ticket-open.inc.php +++ b/include/staff/ticket-open.inc.php @@ -348,6 +348,7 @@ if ($_POST) </tbody> <tbody id="dynamic-form"> <?php + $options = array('mode' => 'create'); foreach ($forms as $form) { print $form->getForm($_SESSION[':form-data'])->getMedia(); include(STAFFINC_DIR . 'templates/dynamic-form.tmpl.php'); -- GitLab