aboutsummaryrefslogtreecommitdiffhomepage
path: root/templates/settings_field.php
diff options
context:
space:
mode:
authorwinter2025-01-18 20:02:39 +0000
committerwinter2025-01-18 20:02:39 +0000
commit66bdcf04f431d615b5fac93e7677e7304888e90c (patch)
treed75f1b299e8ed2ff8d2fd6ccd42185cfb06b6729 /templates/settings_field.php
parent00ab9734e880219fa68fed98cefda5ce12958e4b (diff)
implement settings editor page
Diffstat (limited to 'templates/settings_field.php')
-rw-r--r--templates/settings_field.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/templates/settings_field.php b/templates/settings_field.php
new file mode 100644
index 0000000..15b6c71
--- /dev/null
+++ b/templates/settings_field.php
@@ -0,0 +1,31 @@
+<?php
+$id = "setting-$key";
+$inputType = 'text';
+if (($type ?? null) == 'boolean') {
+ $inputType = 'select';
+ $options = ['true', 'false'];
+}
+// php converts . to _ in $_POST for some mikuforsaken reason so i'm working around it like this
+$fieldName = str_replace('.', '<DOT>', $key);
+?>
+<div class="row">
+
+ <label for="<?= $id ?>">
+ <strong><?= $name ?></strong><br>
+ <?= $description ?>
+ </label>
+
+ <?php if ($inputType == 'select'): ?>
+
+ <select id="<?= $id ?>" name="<?= $fieldName ?>">
+ <?php foreach ($options as $o): ?>
+ <option <?= $value == $o ? 'selected' : '' ?>><?= $o ?></option>
+ <?php endforeach; ?>
+ </select>
+
+ <?php else: ?>
+
+ <input id="<?= $id ?>" name="<?= $fieldName ?>" value="<?= $value ?>" type="<?= $inputType ?>" autocomplete="off">
+
+ <?php endif; ?>
+</div> \ No newline at end of file