fix: [element:generic_index] Toggle field passes expected data format

pull/37/head
mokaddem 2021-01-18 08:51:16 +01:00
parent 13c8f3f7c5
commit c70ce5170f
2 changed files with 18 additions and 17 deletions

View File

@ -59,18 +59,7 @@ echo $this->element('genericElements/IndexTable/index_table', [
__('Only one template per scope can be set as the default template'), __('Only one template per scope can be set as the default template'),
'{{0}}', '{{0}}',
]), ]),
'type' => [ 'type' => '{{0}}',
'function' => function($row, $data) {
$conflictingTemplate = getConflictingTemplate($row, $data);
if (!empty($conflictingTemplate)) {
return 'confirm-danger';
}
return 'confirm-warning';
},
'data' => [
'defaultTemplatePerScope' => $defaultTemplatePerScope
]
],
'confirmText' => __('Yes, set as default'), 'confirmText' => __('Yes, set as default'),
'arguments' => [ 'arguments' => [
'titleHtml' => ['name'], 'titleHtml' => ['name'],
@ -99,6 +88,18 @@ echo $this->element('genericElements/IndexTable/index_table', [
'defaultTemplatePerScope' => $defaultTemplatePerScope '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?'), 'titleHtml' => __('Remove {{0}} as the default template?'),
'type' => 'confirm-warning', 'type' => 'confirm-warning',
'confirmText' => __('Yes, do not set as default'), 'confirmText' => __('Yes, do not set as default'),
'arguements' => [ 'arguments' => [
'titleHtml' => ['name'], 'titleHtml' => ['name'],
] ]
] ]

View File

@ -50,10 +50,10 @@
unset($stringArrayEnable['arguments']); unset($stringArrayEnable['arguments']);
$stringArrayDisable = $field['toggle_data']['confirm']['disable']; $stringArrayDisable = $field['toggle_data']['confirm']['disable'];
unset($stringArrayDisable['arguments']); unset($stringArrayDisable['arguments']);
$confirmOptions = array_merge( $confirmOptions = [
$this->DataFromPath->buildStringsInArray($stringArrayEnable, $row, $field['toggle_data']['confirm']['enable']['arguments'], ['highlight' => true]), 'enable' => $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]), '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']); $url = $this->DataFromPath->buildStringFromDataPath($field['url'], $row, $field['url_params_vars']);
?> ?>