[5.x]: ApplyFieldSaveEvent
has inconsistent $event->field
value
#16156
Labels
ApplyFieldSaveEvent
has inconsistent $event->field
value
#16156
What happened?
Sidenote...
craft\services\Fields::EVENT_BEFORE_APPLY_FIELD_SAVE
is not included in the Event Generator.I believe there is a bug in the new
EVENT_BEFORE_APPLY_FIELD_SAVE
event. Specifically, the$event->field
value is inconsistent based on whether you are:Here is my current code (shown below via Xdebug).
Locally, (scenario A) the
$event->field
registers as a Google Maps field...But if you roll back the database and apply the modified Project Config (scenario B), the
$event->field
registers as an Ether field...This is tangentially related to a very important question...
⭐️ What is the best way to determine both the before and after types of the changing field? ⭐
I noticed that
ProjectConfig::EVENT_UPDATE_ITEM
emits a ConfigEvent, which contains both an$oldValue
and a$newValue
. Is it possible to introduce something similar to the ApplyFieldSaveEvent?Steps to reproduce
You can get the mostly-functional dev version of this feature here...
...however...
Expected behavior
The
$event->field
value should be consistent whether I am changing the field type initially, or applying that change via Project Config.Additionally, there should be an easy way to determine what the field type is changing to and from.
Actual behavior
$event->field
to a Google Maps field, but$event->field
to an Ether field.Craft CMS version
5.5.2
PHP version
8.2.22
Operating system and version
Linux 6.11.6-orbstack-00279-g28c6c77332e6
Database type and version
MySQL 8.0.36
Image driver and version
Imagick 3.7.0 (ImageMagick 6.9.11-60)
Installed plugins and versions
The text was updated successfully, but these errors were encountered: