From e41bf0491e933285a5c83ca5e3efa94b971ba7cc Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Fri, 21 Aug 2015 10:44:21 -0500
Subject: [PATCH] task: Fix save with priority field in custom data

---
 include/class.forms.php | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/include/class.forms.php b/include/class.forms.php
index 1ee044aa1..107cea8bf 100644
--- a/include/class.forms.php
+++ b/include/class.forms.php
@@ -597,6 +597,8 @@ class FormField {
     function getClean() {
         if (!isset($this->_clean)) {
             $this->_clean = (isset($this->value))
+                // XXX: The widget value may be parsed already if this is
+                //      linked to dynamic data via ::getAnswer()
                 ? $this->value : $this->parse($this->getWidget()->value);
 
             if ($vs = $this->get('cleaners')) {
@@ -2065,6 +2067,8 @@ class PriorityField extends ChoiceField {
     }
 
     function to_php($value, $id=false) {
+        if ($value instanceof Priority)
+            return $value;
         if (is_array($id)) {
             reset($id);
             $id = key($id);
@@ -2083,6 +2087,13 @@ class PriorityField extends ChoiceField {
             : $prio;
     }
 
+    function display($prio) {
+        if (!$prio instanceof Priority)
+            return parent::display($prio);
+        return sprintf('<span style="padding: 2px; background-color: %s">%s</span>',
+            $prio->getColor(), Format::htmlchars($prio->getDesc()));
+    }
+
     function toString($value) {
         return ($value instanceof Priority) ? $value->getDesc() : $value;
     }
-- 
GitLab