diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php index 75c3e9904136dcab723426ed2159f6a07007fd23..f5037503d541b97d6d07974b8cb2e60420da20d1 100644 --- a/include/class.dynamic_forms.php +++ b/include/class.dynamic_forms.php @@ -1194,11 +1194,10 @@ class DynamicFormEntry extends VerySimpleModel { $field = $a->getField(); if (!$field->hasData() || $field->isPresentationOnly()) continue; - $after = $field->to_database($field->getClean()); - $before = $field->to_database($a->getValue()); - if ($before == $after) + $changes = $field->getChanges(); + if (!$changes) continue; - $fields[$field->get('id')] = array($before, $after); + $fields[$field->get('id')] = $changes; } return $fields; } diff --git a/include/class.forms.php b/include/class.forms.php index 0cbabf90b238cd0fd84fb6fa71fe4bbdca9f2f83..38388d2597e0c36441b371180d2030d8bc9f807f 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -1677,6 +1677,24 @@ class BooleanField extends FormField { return ($value) ? __('Yes') : __('No'); } + function getClean($validate=true) { + if (!isset($this->_clean)) { + $this->_clean = (isset($this->value)) + ? $this->value : $this->getValue(); + + if ($this->isVisible() && $validate) + $this->validateEntry($this->_clean); + } + return $this->_clean; + } + + function getChanges() { + $new = $this->getValue(); + $old = $this->answer ? $this->answer->getValue() : $this->get('default'); + + return ($old != $new) ? array($this->to_database($old), $this->to_database($new)) : false; + } + function getSearchMethods() { return array( 'set' => __('checked'),