You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As of Craft 4, elements keep track of changes to their attributes and fields using the $_dirtyAttributes and $_dirtyFields properties when the element is saved directly, and using the $_modifiedAttributes and $_modifiedFields properties when the element is saved via a draft.
When saving an element that does not support drafts such a User, however, $_dirtyFields stores all custom fields regardless of whether any field values were actually changed. Additionally, the non-existent field changes are registered in the changedfields database table.
Steps to replicate:
Add a custom field to the user field layout.
Visit the user edit page in the CP.
Don’t change the custom fields value.
Look in the changedfields database table and see that a row is added for the user and field (or the dateUpdated column is updated if the row already existed).
It would be great if $_dirtyFields would track only fields that have actually changed, much like $_dirtyAttributesonly tracks changed attributes.
This would additionally make the content in the changedfields database table more accurate, helping to pave the way for a reliable element history feature.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
As of Craft 4, elements keep track of changes to their attributes and fields using the
$_dirtyAttributes
and$_dirtyFields
properties when the element is saved directly, and using the$_modifiedAttributes
and$_modifiedFields
properties when the element is saved via a draft.When saving an element that does not support drafts such a User, however,
$_dirtyFields
stores all custom fields regardless of whether any field values were actually changed. Additionally, the non-existent field changes are registered in thechangedfields
database table.Steps to replicate:
changedfields
database table and see that a row is added for the user and field (or thedateUpdated
column is updated if the row already existed).It would be great if
$_dirtyFields
would track only fields that have actually changed, much like$_dirtyAttributes
only tracks changed attributes.This would additionally make the content in the
changedfields
database table more accurate, helping to pave the way for a reliable element history feature.Beta Was this translation helpful? Give feedback.
All reactions