diff --git a/CHANGELOG.md b/CHANGELOG.md index afe0b9b..fc27ac3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ -## 5.0.0 - 2024-03-01 +## 5.0.0-rc2 - 2024-04-29 +### Fixed +- Fix element validation issue when saving (Fixes #478) + +## 5.0.0-rc1 - 2024-03-01 ### Changed - Add support for Craft 5 diff --git a/src/models/data/SeoData.php b/src/models/data/SeoData.php index ddc8d66..2501bf4 100644 --- a/src/models/data/SeoData.php +++ b/src/models/data/SeoData.php @@ -452,9 +452,12 @@ private function _getVariables () if ($this->_element !== null) { - foreach (array_keys($this->_element->fields()) as $name) + foreach ($this->_element->getFieldLayout()->getCustomFields() as $field) { + $name = $field->handle; + if ($name !== $this->_handle) $variables[$name] = $this->_element->$name ?? null; + } if (!array_key_exists('type', $variables) && $this->_element->hasMethod('getType')) $variables['type'] = $this->_element->getType(); @@ -462,10 +465,11 @@ private function _getVariables () if (!array_key_exists('section', $variables) && $this->_element->hasMethod('getSection')) $variables['section'] = $this->_element->getSection(); - $variables = array_merge( - $variables, - $this->_element->toArray($this->_element->extraFields(), [], false) - ); + if (!array_key_exists('site', $variables) && $this->_element->hasMethod('getSite')) + $variables['site'] = $this->_element->getSite(); + + if (!array_key_exists('author', $variables) && $this->_element->hasMethod('getAuthor')) + $variables['author'] = $this->_element->getAuthor(); } return $variables;