robwilkerson / CakePHP-Audit-Log-Plugin

Records changes made to an object during CRUD operations.
104 stars 78 forks source link

Auditable Behavior does not Save Empty-ish Values on CREATE #90

Closed ravage84 closed 8 years ago

ravage84 commented 8 years ago

For example when you have form with a checkbox (true/false), it does not save the false value for this form for a NEW record, when the checkbox is not checked.

The causing line is this: https://github.com/robwilkerson/CakePHP-Audit-Log-Plugin/blob/2.0.1/Model/Behavior/AuditableBehavior.php#L169

It seems this was deliberate, but I think it's a somewhat unwanted behavior.

Arguably, this could be a configurable setting.

xhs345 commented 8 years ago

Yes, that's a good point. The circumvent the problem with check boxes the check could also be changed to:
if ( ! (null === $value || $value === '') ) But there might be more cases I'm not think of right now

ravage84 commented 8 years ago

What's the problem of logging an empty value? A empty value is a value nonetheless...

xhs345 commented 8 years ago

After giving it some more thought.. yes, agreed