Field's setValue method should not notify the parent of changes when being called multiple times with the same value

Created on 25 July 2018, almost 7 years ago
Updated 31 January 2023, over 2 years ago

Problem/Motivation

$field->setValue($field->getValue()); - setting a field value with the current field value will notify the parent of changes, but it shouldn't.

Proposed resolution

Keep track of the original field values and notify the parent only in case the value really changed.

Implement onReset($name) similar to the onChange($name) method in ContentEntityBase, which should be called when a value is being reset -

The Initial field value - 'A';
$field->setValue('B'); // on-change is triggered for the change.
$field->setValue('B'); // on-change is not triggered for the change.
$field->setValue('A'); // on-change is not triggered for the change, but on-reset is triggered instead.

This should give us the ability to track changed fields and remove them from the list of changed fields when they are reset. This is needed for #2862574: Add ability to track an entity object's dirty fields (and see if it has changed) β†’ .

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Needs work

Version

10.1 ✨

Component
EntityΒ  β†’

Last updated 36 minutes ago

Created by

πŸ‡©πŸ‡ͺGermany hchonov πŸ‡ͺπŸ‡ΊπŸ‡©πŸ‡ͺπŸ‡§πŸ‡¬

Live updates comments and jobs are added and updated live.
  • Needs framework manager review

    It is used to alert the framework manager core committer(s) that an issue significantly impacts (or has the potential to impact) multiple subsystems or represents a significant change or addition in architecture or public APIs, and their signoff is needed (see the governance policy draft for more information). If an issue significantly impacts only one subsystem, use Needs subsystem maintainer review instead, and make sure the issue component is set to the correct subsystem.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request β†’ as a guide.

    Not sure how this one survived the review bot.

    But seems like more a feature request then bug to me but will leave as is.

    Any fix will need test cases and probably a change record

    Tagging for framework manager review all incase they have input.

    Thanks!

Production build 0.71.5 2024