Skip to content

Commit

Permalink
4.14.8.1 - Fix Field::afterSave()
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Feb 21, 2025
1 parent 40fc7da commit 34ff6e4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release Notes for Craft CMS 4

## 4.14.8.1 - 2025-02-20

- Fixed a bug where newly-created custom fields wouldn’t have their full settings intact for `afterSave()`.

## 4.14.8 - 2025-02-20

- Fixed a bug where scrollable panes weren’t automatically scrolling when dragging objects near their edges. ([#16738](https://github.com/craftcms/cms/issues/16738))
Expand Down
2 changes: 1 addition & 1 deletion src/config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
return [
'id' => 'CraftCMS',
'name' => 'Craft CMS',
'version' => '4.14.8',
'version' => '4.14.8.1',
'schemaVersion' => '4.5.3.0',
'minVersionRequired' => '3.7.11',
'basePath' => dirname(__DIR__), // Defines the @app alias
Expand Down
10 changes: 8 additions & 2 deletions src/services/Fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -1574,6 +1574,9 @@ public function applyFieldSave(string $fieldUid, array $data, string $context):
$oldSettings = $fieldRecord->getOldAttribute('settings');
$oldField = !$isNewField ? $this->getFieldById($fieldRecord->id) : null;

// For control panel save requests, make sure we have all the custom data already saved on the object.
$field = $this->_savingFields[$fieldUid] ?? null;

// Fire a 'beforeApplyFieldSave' event
if ($this->hasEventHandlers(self::EVENT_BEFORE_APPLY_FIELD_SAVE)) {
$this->trigger(self::EVENT_BEFORE_APPLY_FIELD_SAVE, new ApplyFieldSaveEvent([
Expand Down Expand Up @@ -1670,8 +1673,11 @@ public function applyFieldSave(string $fieldUid, array $data, string $context):
// Tell the current CustomFieldBehavior class about the field
CustomFieldBehavior::$fieldHandles[$fieldRecord->handle] = true;

// Now get the field with its new settings intact
$field = $this->getFieldById($fieldRecord->id);
// Now get the field, if it's not a field save request
$field ??= $this->getFieldById($fieldRecord->id);
if ($isNewField) {
$field->id = $fieldRecord->id;
}

if (!$isNewField) {
// Set the old field handle and settings on the model in case the field type needs to do something with it
Expand Down

0 comments on commit 34ff6e4

Please sign in to comment.