diff options
Diffstat (limited to 'templates/settings_field.php')
| -rw-r--r-- | templates/settings_field.php | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/templates/settings_field.php b/templates/settings_field.php index 1ebbfb3..fe68a52 100644 --- a/templates/settings_field.php +++ b/templates/settings_field.php @@ -1,13 +1,14 @@ <?php -$id = "setting-$key"; +$id ??= "setting-$key"; $settingType = $type ?? 'text'; $inputType = $settingType; if ($settingType == 'boolean') { - $inputType = 'select'; - $options = ['true', 'false']; + $inputType = 'checkbox'; + $options = ['false', 'true']; + $checked = $value == 'true' || $value == true; } // php converts . to _ in $_POST for some mikuforsaken reason so i'm working around it like this -$fieldName = str_replace('.', '<DOT>', $key); +$fieldName ??= str_replace('.', '<DOT>', $key); ?> <div class="row"> @@ -24,6 +25,11 @@ $fieldName = str_replace('.', '<DOT>', $key); <?php endforeach; ?> </select> + <?php elseif ($inputType == 'checkbox'): ?> + + <input type="hidden" name="<?= $fieldName ?>" value="<?= $options[0] ?>"> + <input id="<?= $id ?>" name="<?= $fieldName ?>" value="<?= $options[1] ?>" type="checkbox" <?= $checked ? 'checked' : '' ?> autocomplete="off"> + <?php elseif ($inputType == 'longtext'): ?> <textarea id="<?= $id ?>" name="<?= $fieldName ?>" autocomplete="off"><?= $value ?></textarea> |
