diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ebf688..e19aa61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Release Notes for CKEditor for Craft CMS +## Unreleased + +- Fixed a bug where CKEditor field values weren’t always getting propagated to other sites (with duplicated nested entries) when creating a new element. ([#479](https://github.com/craftcms/ckeditor/pull/479)) + ## 4.11.0 - 2025-11-19 - Statically-rendered CKEditor fields are now shown in read-only mode. ([#466](https://github.com/craftcms/ckeditor/pull/466)) diff --git a/src/Field.php b/src/Field.php index d559b4d..e8abfc1 100644 --- a/src/Field.php +++ b/src/Field.php @@ -372,6 +372,10 @@ private static function adjustFieldValues( } if ($resave) { + if (version_compare(Craft::$app->getVersion(), '5.9.0', '>=')) { + /** @phpstan-ignore-next-line */ + $owner->propagateRequired = false; + } Craft::$app->getElements()->saveElement($owner, false, $propagate, false); } } @@ -1904,4 +1908,20 @@ public function setEnableSourceEditingForNonAdmins(bool $value): void { $this->sourceEditingGroups = $value ? '*' : ['__ADMINS__']; } + + /** + * @inheritdoc + */ + public function propagateValue(ElementInterface $from, ElementInterface $to): void + { + /** @phpstan-ignore-next-line */ + parent::propagateValue($from, $to); + + if (!$from->propagateAll) { + // NestedElementManager won't duplicate the nested entries automatically, + // because the field has a value in the target site (the HTML content), so isValueEmpty() is false. + /** @phpstan-ignore-next-line */ + self::entryManager($this)->duplicateNestedElements($from, $to, force: true); + } + } }