fix: [component:CRUD] Restrict metafields to only the object being viewed

pull/37/head
mokaddem 2020-12-08 15:03:38 +01:00
parent 52fef41f3c
commit 6b4565cdf0
1 changed files with 4 additions and 2 deletions

View File

@ -241,8 +241,10 @@ class CRUDComponent extends Component
return $data;
}
$query = $this->MetaFields->MetaTemplates->find();
$query->contain('MetaTemplateFields', function ($q) {
return $q->innerJoinWith('MetaFields');
$metaFields = $this->Table->metaFields;
$query->contain('MetaTemplateFields', function ($q) use ($id, $metaFields) {
return $q->innerJoinWith('MetaFields')
->where(['MetaFields.scope' => $metaFields, 'MetaFields.parent_id' => $id]);
});
$query->innerJoinWith('MetaTemplateFields', function ($q) {
return $q->contain('MetaFields')->innerJoinWith('MetaFields');