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,
|
|
|
|
]);
|
|
|
|
|
|
|
|
$inputGroupSave = $this->Bootstrap->genNode('div', [
|
2021-09-18 10:31:05 +02:00
|
|
|
'class' => ['d-none', 'position-relative', 'input-group-actions'],
|
2021-07-26 11:16:52 +02:00
|
|
|
], implode('', [
|
|
|
|
$this->Bootstrap->genNode('a', [
|
|
|
|
'class' => ['position-absolute', 'fas fa-times', 'p-abs-center-y', 'text-reset text-decoration-none', 'btn-reset-setting'],
|
|
|
|
'href' => '#',
|
|
|
|
]),
|
|
|
|
$this->Bootstrap->genNode('button', [
|
|
|
|
'class' => ['btn', 'btn-success', 'btn-save-setting'],
|
|
|
|
'type' => 'button',
|
|
|
|
], __('save')),
|
|
|
|
]));
|
|
|
|
$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;
|
|
|
|
?>
|