Skip to content

Commit 3002b5a

Browse files
committed
Fix element validation issue when saving
Fixes #478
1 parent 5994e31 commit 3002b5a

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

CHANGELOG.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
## 5.0.0 - 2024-03-01
1+
## 5.0.0-rc2 - 2024-04-29
2+
### Fixed
3+
- Fix element validation issue when saving (Fixes #478)
4+
5+
## 5.0.0-rc1 - 2024-03-01
26
### Changed
37
- Add support for Craft 5
48

src/models/data/SeoData.php

+9-5
Original file line numberDiff line numberDiff line change
@@ -452,20 +452,24 @@ private function _getVariables ()
452452

453453
if ($this->_element !== null)
454454
{
455-
foreach (array_keys($this->_element->fields()) as $name)
455+
foreach ($this->_element->getFieldLayout()->getCustomFields() as $field) {
456+
$name = $field->handle;
457+
456458
if ($name !== $this->_handle)
457459
$variables[$name] = $this->_element->$name ?? null;
460+
}
458461

459462
if (!array_key_exists('type', $variables) && $this->_element->hasMethod('getType'))
460463
$variables['type'] = $this->_element->getType();
461464

462465
if (!array_key_exists('section', $variables) && $this->_element->hasMethod('getSection'))
463466
$variables['section'] = $this->_element->getSection();
464467

465-
$variables = array_merge(
466-
$variables,
467-
$this->_element->toArray($this->_element->extraFields(), [], false)
468-
);
468+
if (!array_key_exists('site', $variables) && $this->_element->hasMethod('getSite'))
469+
$variables['site'] = $this->_element->getSite();
470+
471+
if (!array_key_exists('author', $variables) && $this->_element->hasMethod('getAuthor'))
472+
$variables['author'] = $this->_element->getAuthor();
469473
}
470474

471475
return $variables;

0 commit comments

Comments
 (0)