Skip to content
Snippets Groups Projects
Commit e41bf049 authored by Jared Hancock's avatar Jared Hancock
Browse files

task: Fix save with priority field in custom data

parent f826189b
No related branches found
No related tags found
No related merge requests found
...@@ -597,6 +597,8 @@ class FormField { ...@@ -597,6 +597,8 @@ class FormField {
function getClean() { function getClean() {
if (!isset($this->_clean)) { if (!isset($this->_clean)) {
$this->_clean = (isset($this->value)) $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); ? $this->value : $this->parse($this->getWidget()->value);
if ($vs = $this->get('cleaners')) { if ($vs = $this->get('cleaners')) {
...@@ -2065,6 +2067,8 @@ class PriorityField extends ChoiceField { ...@@ -2065,6 +2067,8 @@ class PriorityField extends ChoiceField {
} }
function to_php($value, $id=false) { function to_php($value, $id=false) {
if ($value instanceof Priority)
return $value;
if (is_array($id)) { if (is_array($id)) {
reset($id); reset($id);
$id = key($id); $id = key($id);
...@@ -2083,6 +2087,13 @@ class PriorityField extends ChoiceField { ...@@ -2083,6 +2087,13 @@ class PriorityField extends ChoiceField {
: $prio; : $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) { function toString($value) {
return ($value instanceof Priority) ? $value->getDesc() : $value; return ($value instanceof Priority) ? $value->getDesc() : $value;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment