fix: [settings:fields] Added support of textarea and fixed variant from severity

pull/70/head
mokaddem 2021-07-30 08:17:00 +02:00
parent a82c8fe62b
commit 64646aa118
1 changed files with 20 additions and 17 deletions

View File

@ -1,8 +1,10 @@
<?php
if ($setting['type'] == 'string' || empty($setting['type'])) {
if ($setting['type'] == 'string' || $setting['type'] == 'textarea' || empty($setting['type'])) {
$input = (function ($settingName, $setting, $appView) {
$settingId = str_replace('.', '_', $settingName);
return $appView->Bootstrap->genNode('input', [
return $appView->Bootstrap->genNode(
$setting['type'] == 'textarea' ? 'textarea' : 'input',
[
'class' => [
'form-control',
'pr-4',
@ -10,13 +12,14 @@
(!empty($setting['error']) ? "border-{$appView->get('variantFromSeverity')[$setting['severity']]}" : ''),
(!empty($setting['error']) ? $appView->get('variantFromSeverity')[$setting['severity']] : ''),
],
'type' => 'text',
($setting['type'] == 'textarea' ? '' : 'type') => ($setting['type'] == 'textarea' ? '' : 'text'),
'id' => $settingId,
'data-setting-name' => $settingName,
'value' => isset($setting['value']) ? $setting['value'] : "",
'placeholder' => $setting['default'] ?? '',
'aria-describedby' => "{$settingId}Help"
]);
]
);
})($settingName, $setting, $this);
} elseif ($setting['type'] == 'boolean') {
@ -26,7 +29,7 @@
'class' => [
'custom-control-input',
(!empty($setting['error']) ? 'is-invalid' : ''),
(!empty($setting['error']) && $setting['severity'] == 'warning' ? 'warning' : ''),
(!empty($setting['error']) ? $appView->get('variantFromSeverity')[$setting['severity']] : ''),
],
'type' => 'checkbox',
'value' => !empty($setting['value']) ? 1 : 0,