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

plugins: Fix saving and loading of checkbox fields

parent 57448f36
Branches
Tags
No related merge requests found
......@@ -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;
}
......
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment