Support unsetting a value when using "Entity: set field value"

Created on 5 March 2025, about 1 month ago

Problem/Motivation

I've been using the ECA VBO plug-in and the ECA Content (Entity: Set field value) plugins to allow editors to modify the review status of content. This works great for adding a "review status: needs review" for a field but once done I wanted a way to clear the review status to return it to the previous state. I thought this wouldn't be too difficult, but...

After trying "Set and clear previous value" and "Set and enforce clear previous value" with an empty field value and attempting to use the "undefined" method (I couldn't see any documentation which would tells me whether the latter exists to mean that the method is undefined, or if it is a method for setting the field value as undefined) - it seems there is no way to unset a field value. I asked on slack if anyone knew how.

It turns out that, apparently unsetting, values (except for removing specific entity references), or setting the value to null aka empty is not supported!

This seems like an oversight given the ambitious scope of the ECA module. If you can't undo the kinds of transformations that are supported, it leaves you with an incomplete system, frustration in the assumption that you're doing something wrong and eventually looking for more complicated approaches which defeat the purpose of using ECA in the first place.

Steps to reproduce

  1. Try to use any of the existing methods of "ECA Content: Set Entity Value" to empty a field value.
  2. See it fail.

Proposed resolution

I don't know which would be better interface solution but here's the two ways I could see this working:

  1. "clear/empty the field value" could be introduced as a method (which needs to pass some sort of validation for fields that can't be empty)
  2. "field value" box should accept either an empty value or accept a token for 'null', using existing validation for those methods to make sure nothing breaks.

As far as I can see an empty field value seems to currently be interpreted as "do not change existing field value" even when the method includes the words "enforce clear previous value" so perhaps an additional method may be necessary if we want to people's existing models which may rely on this fallback, suddenly having a change in behavior due to an update/patch.

If however we agree that "enforce clear previous value" will already be interpreted by most people as doing what it says then perhaps this could be considered a bug which needs to be remedied by indeed enforcing it.

Remaining tasks

  • Decide on the two approaches above
  • Draft and suggest code changes to the ECA Content plug in
  • Test changes
  • Review
  • Merge

User interface changes

An additional method being available, or the changed behavior being noted in the field value entry box label.

API changes

N/A (I think)

Data model changes

N/A (I think)

Feature request
Status

Active

Version

2.1

Component

Code

Created by

🇬🇧United Kingdom jacobupal Leeds

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @jacobupal
  • 🇬🇧United Kingdom jacobupal Leeds
  • 🇩🇪Germany jurgenhaas Gottmadingen

    Thanks for creating this feature request with all the details in the IS.

    I'd prefer option 1 to introduce a new method "Empty field". The validation, that the given field can be emptied should happen in the access control, and the execute will then just have to do the actual work, if it is possible and allowed.

Production build 0.71.5 2024