aboutsummaryrefslogtreecommitdiffhomepage
path: root/templates/settings_field.php
diff options
context:
space:
mode:
authorwinter2025-01-26 15:25:17 +0000
committerwinter2025-01-26 15:25:17 +0000
commit890dad24d6c095c41e6358b2a6cb61f1b6c2f6ad (patch)
treea662dfd61585b755054075cd93121a9c70a48983 /templates/settings_field.php
parent5841d6550936e1fc34f1fbdf4325b1e27ff79230 (diff)
add user settings / preferences
Diffstat (limited to 'templates/settings_field.php')
-rw-r--r--templates/settings_field.php14
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>