From 02766c642b943e01ec6ab2cdd34b11dddffd1b77 Mon Sep 17 00:00:00 2001
From: Peter Rotich <peter@osticket.com>
Date: Fri, 10 Jul 2015 05:56:34 +0000
Subject: [PATCH] Use AbstractForm for Internal Task Form

---
 include/class.task.php | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/include/class.task.php b/include/class.task.php
index 7cede6194..31fcf11b2 100644
--- a/include/class.task.php
+++ b/include/class.task.php
@@ -1273,33 +1273,36 @@ class TaskForm extends DynamicForm {
         return static::$instance;
     }
 
-    static function getInternalForm($source=null) {
+    static function getInternalForm($source=null, $options=array()) {
         if (!isset(static::$internalForm))
-            static::$internalForm = new SimpleForm(self::getInternalFields(), $source);
+            static::$internalForm = new TaskInternalForm($source, $options);
 
         return static::$internalForm;
     }
+}
+
+class TaskInternalForm
+extends AbstractForm {
+    static $layout = 'GridFormLayout';
+
+    function buildFields() {
 
-    static function getInternalFields() {
-        return array(
+        $fields = array(
                 'dept_id' => new DepartmentField(array(
                     'id'=>1,
                     'label' => __('Department'),
-                    'flags' => hexdec(0X450F3),
                     'required' => true,
                     'layout' => new GridFluidCell(6),
                     )),
                 'staff_id' => new AssigneeField(array(
                     'id'=>2,
                     'label' => __('Assignee'),
-                    'flags' => hexdec(0X450F3),
                     'required' => false,
                     'layout' => new GridFluidCell(6),
                     )),
                 'duedate'  =>  new DatetimeField(array(
                     'id' => 3,
                     'label' => __('Due Date'),
-                    'flags' => hexdec(0X450B3),
                     'required' => false,
                     'configuration' => array(
                         'min' => Misc::gmtime(),
@@ -1310,6 +1313,14 @@ class TaskForm extends DynamicForm {
                     )),
 
             );
+
+        $mode = @$this->options['mode'];
+        if ($mode && $mode == 'edit') {
+            unset($fields['dept_id']);
+            unset($fields['staff_id']);
+        }
+
+        return $fields;
     }
 }
 
-- 
GitLab