From b3f10fbb6dc7eed7f2f70bfc5bdf83ab30b7b380 Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Tue, 25 Mar 2014 16:49:32 -0500 Subject: [PATCH] plugins: Fix saving and loading of checkbox fields --- include/class.forms.php | 2 +- include/class.plugin.php | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/class.forms.php b/include/class.forms.php index 5955ec76d..42f4651a1 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -937,7 +937,7 @@ class Widget { $this->value = $this->getValue(); if (!isset($this->value) && is_object($this->field->getAnswer())) $this->value = $this->field->getAnswer()->getValue(); - if (!isset($this->value) && $this->field->value) + if (!isset($this->value) && isset($this->field->value)) $this->value = $this->field->value; } diff --git a/include/class.plugin.php b/include/class.plugin.php index 6a8ac830b..f571ad75d 100644 --- a/include/class.plugin.php +++ b/include/class.plugin.php @@ -9,6 +9,8 @@ class PluginConfig extends Config { // Use parent constructor to place configurable information into the // central config table in a namespace of "plugin.<id>" parent::Config("plugin.$name"); + foreach ($this->getOptions() as $name => $field) + $this->config[$name]['value'] = $field->to_php($this->get($name)); } /* abstract */ @@ -56,8 +58,14 @@ class PluginConfig extends Config { $commit = $this->pre_save($config, $errors); } $errors += $f->errors(); - if ($commit && count($errors) === 0) - return $this->updateAll($config); + if ($commit && count($errors) === 0) { + $dbready = array(); + foreach ($config as $name => $val) { + $field = $f->getField($name); + $dbready[$name] = $field->to_database($val); + } + return $this->updateAll($dbready); + } return false; } -- GitLab