2021-07-26 11:16:52 +02:00
|
|
|
<?php
|
|
|
|
$settingId = str_replace('.', '_', $settingName);
|
|
|
|
|
|
|
|
$dependsOnHtml = '';
|
|
|
|
if (!empty($setting['dependsOn'])) {
|
|
|
|
$dependsOnHtml = $this->Bootstrap->genNode('span', [
|
|
|
|
'class' => [
|
2021-09-17 17:51:45 +02:00
|
|
|
'ms-1',
|
2021-07-26 11:16:52 +02:00
|
|
|
'd-inline-block',
|
|
|
|
'depends-on-icon'
|
|
|
|
],
|
|
|
|
'style' => 'min-width: 0.75em;',
|
|
|
|
'title' => __('This setting depends on the validity of: {0}', h($setting['dependsOn'])),
|
|
|
|
], $this->Bootstrap->genNode('sup', [
|
|
|
|
'class' => $this->FontAwesome->getClass('info'),
|
|
|
|
]));
|
|
|
|
}
|
|
|
|
$label = $this->Bootstrap->genNode('label', [
|
2021-09-17 17:51:45 +02:00
|
|
|
'class' => ['form-label', 'fw-bolder', 'mb-0'],
|
2021-07-26 11:16:52 +02:00
|
|
|
'for' => $settingId
|
2021-07-30 09:23:19 +02:00
|
|
|
], sprintf('<a id="lb-%s" href="#lb-%s" class="text-reset text-decoration-none">%s</a>', h($settingId), h($settingId), h($setting['name'])) . $dependsOnHtml);
|
2021-07-26 11:16:52 +02:00
|
|
|
|
|
|
|
$description = '';
|
|
|
|
if (!empty($setting['description']) && (empty($setting['type']) || $setting['type'] != 'boolean')) {
|
|
|
|
$description = $this->Bootstrap->genNode('small', [
|
|
|
|
'class' => ['form-text', 'text-muted', 'mt-0'],
|
|
|
|
'id' => "{$settingId}Help"
|
|
|
|
], h($setting['description']));
|
|
|
|
}
|
|
|
|
$textColor = 'text-warning';
|
|
|
|
if (!empty($setting['severity'])) {
|
|
|
|
$textColor = "text-{$this->get('variantFromSeverity')[$setting['severity']]}";
|
|
|
|
}
|
|
|
|
$validationError = $this->Bootstrap->genNode('div', [
|
|
|
|
'class' => ['d-block', 'invalid-feedback', $textColor],
|
|
|
|
], (!empty($setting['error']) ? h($setting['errorMessage']) : ''));
|
|
|
|
|
|
|
|
$input = $this->element('Settings/field', [
|
|
|
|
'setting' => $setting,
|
|
|
|
'settingName' => $settingName,
|
|
|
|
]);
|
|
|
|
|
2021-09-28 09:23:02 +02:00
|
|
|
$inputGroupSave = $this->Bootstrap->button([
|
|
|
|
'icon' => 'times',
|
|
|
|
'variant' => 'secondary',
|
|
|
|
'class' => ['btn-setting-action', 'btn-reset-setting', 'd-none'],
|
|
|
|
]);
|
|
|
|
$inputGroupSave .= $this->Bootstrap->button([
|
|
|
|
'text' => __('save'),
|
|
|
|
'variant' => 'success',
|
|
|
|
'class' => ['btn-setting-action', 'btn-save-setting', 'd-none'],
|
|
|
|
]);
|
2021-07-26 11:16:52 +02:00
|
|
|
$inputGroup = $this->Bootstrap->genNode('div', [
|
|
|
|
'class' => ['input-group'],
|
|
|
|
], implode('', [$input, $inputGroupSave]));
|
|
|
|
|
|
|
|
$container = $this->Bootstrap->genNode('div', [
|
2021-09-17 17:51:45 +02:00
|
|
|
'class' => ['setting-group', 'row', 'mb-2']
|
2021-07-26 11:16:52 +02:00
|
|
|
], implode('', [$label, $inputGroup, $description, $validationError]));
|
|
|
|
|
|
|
|
echo $container;
|
|
|
|
?>
|