From c70ce5170fa8b763f0024325419e554b01229f2c Mon Sep 17 00:00:00 2001 From: mokaddem Date: Mon, 18 Jan 2021 08:51:16 +0100 Subject: [PATCH] fix: [element:generic_index] Toggle field passes expected data format --- templates/MetaTemplates/index.php | 27 ++++++++++--------- .../IndexTable/Fields/toggle.php | 8 +++--- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/templates/MetaTemplates/index.php b/templates/MetaTemplates/index.php index 559ead5..882ca4e 100644 --- a/templates/MetaTemplates/index.php +++ b/templates/MetaTemplates/index.php @@ -59,18 +59,7 @@ echo $this->element('genericElements/IndexTable/index_table', [ __('Only one template per scope can be set as the default template'), '{{0}}', ]), - 'type' => [ - 'function' => function($row, $data) { - $conflictingTemplate = getConflictingTemplate($row, $data); - if (!empty($conflictingTemplate)) { - return 'confirm-danger'; - } - return 'confirm-warning'; - }, - 'data' => [ - 'defaultTemplatePerScope' => $defaultTemplatePerScope - ] - ], + 'type' => '{{0}}', 'confirmText' => __('Yes, set as default'), 'arguments' => [ 'titleHtml' => ['name'], @@ -99,6 +88,18 @@ echo $this->element('genericElements/IndexTable/index_table', [ 'defaultTemplatePerScope' => $defaultTemplatePerScope ] ] + ], + 'type' => [ + 'function' => function($row, $data) { + $conflictingTemplate = getConflictingTemplate($row, $data); + if (!empty($conflictingTemplate)) { + return 'confirm-danger'; + } + return 'confirm-warning'; + }, + 'data' => [ + 'defaultTemplatePerScope' => $defaultTemplatePerScope + ] ] ] ], @@ -106,7 +107,7 @@ echo $this->element('genericElements/IndexTable/index_table', [ 'titleHtml' => __('Remove {{0}} as the default template?'), 'type' => 'confirm-warning', 'confirmText' => __('Yes, do not set as default'), - 'arguements' => [ + 'arguments' => [ 'titleHtml' => ['name'], ] ] diff --git a/templates/element/genericElements/IndexTable/Fields/toggle.php b/templates/element/genericElements/IndexTable/Fields/toggle.php index 4eabf80..4064c8f 100644 --- a/templates/element/genericElements/IndexTable/Fields/toggle.php +++ b/templates/element/genericElements/IndexTable/Fields/toggle.php @@ -50,10 +50,10 @@ unset($stringArrayEnable['arguments']); $stringArrayDisable = $field['toggle_data']['confirm']['disable']; unset($stringArrayDisable['arguments']); - $confirmOptions = array_merge( - $this->DataFromPath->buildStringsInArray($stringArrayEnable, $row, $field['toggle_data']['confirm']['enable']['arguments'], ['highlight' => true]), - $this->DataFromPath->buildStringsInArray($stringArrayDisable, $row, $field['toggle_data']['confirm']['disable']['arguments'], ['highlight' => true]), - ); + $confirmOptions = [ + 'enable' => $this->DataFromPath->buildStringsInArray($stringArrayEnable, $row, $field['toggle_data']['confirm']['enable']['arguments'], ['highlight' => true]), + 'disable' => $this->DataFromPath->buildStringsInArray($stringArrayDisable, $row, $field['toggle_data']['confirm']['disable']['arguments'], ['highlight' => true]), + ]; } $url = $this->DataFromPath->buildStringFromDataPath($field['url'], $row, $field['url_params_vars']); ?>