fix: error when entity has no meta_fields

pull/89/head
Luciano Righetti 2022-03-09 09:27:37 +01:00
parent 5c520e440d
commit c0a76d3f99
1 changed files with 1 additions and 1 deletions

View File

@ -704,7 +704,7 @@ class CRUDComponent extends Component
if (empty($data)) {
throw new NotFoundException(__('Invalid {0}.', $this->ObjectAlias));
}
if ($this->metaFieldsSupported()) {
if ($this->metaFieldsSupported() && !empty($data['meta_fields'])) {
$usedMetaTemplateIDs = array_values(array_unique(Hash::extract($data['meta_fields'], '{n}.meta_template_id')));
$data = $this->attachMetaTemplatesIfNeeded($data, null, [
'id IN' => $usedMetaTemplateIDs