Hi Jacob. Loving your plugin. One small issue for me. I have fields in my database set to decimal, and the fields are rendered as decimal in the forms. When I save a form without making ANY changes, the following log is created... total_fee changed from 180.00 to 180, discount changed from 0.00 to 0, addon changed from 0.00 to 0.
Any chance you could fix this? Below is my fix, but maybe you have a better solution?
public function logChangesAfterUpdate() { $attributes = [];
/** @var array $dirtyAttributes */
$dirtyAttributes = $this->getDirty();
/** @var array $originalAttributes */
$originalAttributes = $this->getOriginal();
/** @var array $ignoreFieldsLogbook */
$ignoreFieldsLogbook = $this->ignoreFieldsLogbook ?? ['updated_at'];
foreach ($dirtyAttributes as $column => $newValue) {
if (in_array($column, $ignoreFieldsLogbook)) {
continue; //ignore field
}
if ($newValue == $originalAttributes[$column]) {
continue; // ignore field. Possible false dirty. E.g. "1.00 == 1" // CHANGE
}
/** @var Attribute $attributeChanged */
$attributeChanged = new Attribute([
'column' => $column,
'old' => $originalAttributes[$column] ?? null,
'new' => $newValue,
]);
$attributes[] = $attributeChanged->getData();
}
// do not log if no changes // CHANGE
if (count($attributes))
{
$changes = new Changes([
'type' => Changes::TYPE_UPDATED,
'changedAttributes' => $attributes
]);
$this->createLogBookLogItem($changes);
}
$this->createLogBookLogItem($changes);
}
Thank-you