fix: [genericElements:single_view] Only display meta-field box if the view contains some

pull/37/head
mokaddem 2020-12-08 15:05:53 +01:00
parent 6b4565cdf0
commit 8c2f9a6940
1 changed files with 27 additions and 23 deletions

View File

@ -50,32 +50,36 @@
'content' => []
];
foreach($data['metaTemplates'] as $metaTemplate) {
$tabData['navs'][] = $metaTemplate->name;
$fieldsHtml = '<table class="table table-striped">';
foreach ($metaTemplate->meta_template_fields as $metaTemplateField) {
$metaField = $metaTemplateField->meta_fields[0];
$fieldsHtml .= sprintf(
'<tr class="row"><td class="col-sm-2 font-weight-bold">%s</td><td class="col-sm-10">%s</td></tr>',
h($metaField->field),
$this->element(
'/genericElements/SingleViews/Fields/genericField',
[
'data' => $metaField->value,
'field' => [
'raw' => $metaField->value
if (!empty($metaTemplate->meta_template_fields)) {
$tabData['navs'][] = $metaTemplate->name;
$fieldsHtml = '<table class="table table-striped">';
foreach ($metaTemplate->meta_template_fields as $metaTemplateField) {
$metaField = $metaTemplateField->meta_fields[0];
$fieldsHtml .= sprintf(
'<tr class="row"><td class="col-sm-2 font-weight-bold">%s</td><td class="col-sm-10">%s</td></tr>',
h($metaField->field),
$this->element(
'/genericElements/SingleViews/Fields/genericField',
[
'data' => $metaField->value,
'field' => [
'raw' => $metaField->value
]
]
]
)
);
)
);
}
$fieldsHtml .= '</table>';
$tabData['content'][] = $fieldsHtml;
}
$fieldsHtml .= '</table>';
$tabData['content'][] = $fieldsHtml;
}
$metaTemplateTabs = $this->Bootstrap->Tabs([
'pills' => true,
'card' => true,
'data' => $tabData
]);
if (!empty($tabData['navs'])) {
$metaTemplateTabs = $this->Bootstrap->Tabs([
'pills' => true,
'card' => true,
'data' => $tabData
]);
}
}
$ajaxLists = '';
if (!empty($children)) {