element('genericElements/IndexTable/index_table', [
'data' => [
'data' => $data,
'top_bar' => [
'children' => [
[
'type' => 'context_filters',
'context_filters' => $filteringContexts
],
[
'type' => 'search',
'button' => __('Filter'),
'placeholder' => __('Enter value to search'),
'data' => '',
'searchKey' => 'value'
]
]
],
'fields' => [
[
'name' => '#',
'sort' => 'id',
'data_path' => 'id',
],
[
'name' => 'Enabled',
'sort' => 'enabled',
'data_path' => 'enabled',
'element' => 'toggle',
'url' => '/metaTemplates/toggle/{{0}}',
'url_params_vars' => ['id'],
'toggle_data' => [
'editRequirement' => [
'function' => function($row, $options) {
return true;
},
],
'skip_full_reload' => true
]
],
[
'name' => 'Default',
'sort' => 'is_default',
'data_path' => 'is_default',
'element' => 'toggle',
'url' => '/metaTemplates/toggle/{{0}}/{{1}}',
'url_params_vars' => [['datapath' => 'id'], ['raw' => 'is_default']],
'toggle_data' => [
'editRequirement' => [
'function' => function($row, $options) {
return true;
}
],
'confirm' => [
'enable' => [
'titleHtml' => __('Make {{0}} the default template?'),
'bodyHtml' => $this->Html->nestedList([
__('Only one template per scope can be set as the default template'),
'{{0}}',
]),
'type' => '{{0}}',
'confirmText' => __('Yes, set as default'),
'arguments' => [
'titleHtml' => ['name'],
'bodyHtml' => [
[
'function' => function($row, $data) {
$conflictingTemplate = getConflictingTemplate($row, $data);
if (!empty($conflictingTemplate)) {
return sprintf(
"%s %s.