fix: [Component:CRUD] Allow edit of meta-fields and added group_by clause
parent
ff1f8bfc97
commit
52fef41f3c
|
@ -247,6 +247,7 @@ class CRUDComponent extends Component
|
|||
$query->innerJoinWith('MetaTemplateFields', function ($q) {
|
||||
return $q->contain('MetaFields')->innerJoinWith('MetaFields');
|
||||
});
|
||||
$query->group(['MetaTemplates.id']);
|
||||
$metaTemplates = $query->all();
|
||||
$data['metaTemplates'] = $metaTemplates;
|
||||
return $data;
|
||||
|
@ -262,7 +263,7 @@ class CRUDComponent extends Component
|
|||
$metaFields = $query->all();
|
||||
$data['metaFields'] = [];
|
||||
foreach($metaFields as $metaField) {
|
||||
$data['metaFields'][$metaField->field] = $metaField->value;
|
||||
$data['metaFields'][$metaField->meta_template_id][$metaField->field] = $metaField->value;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ foreach($metaTemplatesData as $i => $metaTemplate) {
|
|||
$fieldsHtml = '';
|
||||
foreach ($metaTemplate->meta_template_fields as $metaField) {
|
||||
$metaField->label = Inflector::humanize($metaField->field);
|
||||
$metaField->field = sprintf('%s.%s.%s', 'metaFields', $metaTemplate->id, $metaField->field);
|
||||
$metaField->field = sprintf('%s.%s.%s', 'metaFields', $metaField->meta_template_id, $metaField->field);
|
||||
$fieldsHtml .= $this->element(
|
||||
'genericElements/Form/fieldScaffold', [
|
||||
'fieldData' => $metaField->toArray(),
|
||||
|
|
Loading…
Reference in New Issue