From b3e8e25399d765f5e8e5ed80b085c723d82a86a9 Mon Sep 17 00:00:00 2001
From: Peter Rotich <peter@osticket.com>
Date: Wed, 21 May 2014 15:41:38 +0000
Subject: [PATCH] Show properties config button if the form exists

---
 include/class.dynamic_forms.php    | 4 ++++
 include/staff/dynamic-list.inc.php | 2 +-
 scp/lists.php                      | 5 ++---
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php
index b01871b56..0be50264d 100644
--- a/include/class.dynamic_forms.php
+++ b/include/class.dynamic_forms.php
@@ -916,6 +916,10 @@ class DynamicList extends VerySimpleModel {
         return $this->_form;
     }
 
+    function getForm() {
+        return $this->getConfigurationForm();
+    }
+
     function save($refetch=false) {
         if (count($this->dirty))
             $this->set('updated', new SqlFunction('NOW'));
diff --git a/include/staff/dynamic-list.inc.php b/include/staff/dynamic-list.inc.php
index 157dba28a..a064dc935 100644
--- a/include/staff/dynamic-list.inc.php
+++ b/include/staff/dynamic-list.inc.php
@@ -220,7 +220,7 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info);
                 value="<?php echo $i->get('sort'); ?>"/></td>
             <td><input type="text" size="40" name="value-<?php echo $id; ?>"
                 value="<?php echo $i->get('value'); ?>"/>
-                <?php if ($form->getFields()) { ?>
+                <?php if ($form && $form->getFields()) { ?>
                 <a class="action-button" style="float:none;overflow:inherit"
                     href="#ajax.php/list/item/<?php
                         echo $i->get('id'); ?>/properties"
diff --git a/scp/lists.php b/scp/lists.php
index 66801deee..57ffad7a2 100644
--- a/scp/lists.php
+++ b/scp/lists.php
@@ -6,9 +6,8 @@ $list=null;
 if($_REQUEST['id'] && !($list=DynamicList::lookup($_REQUEST['id'])))
     $errors['err']='Unknown or invalid dynamic list ID.';
 
-if ($list) {
-    $form = DynamicForm::lookup(array('type'=>'L'.$_REQUEST['id']));
-}
+if ($list)
+    $form = $list->getForm();
 
 if($_POST) {
     $fields = array('name', 'name_plural', 'sort_mode', 'notes');
-- 
GitLab