aboutsummaryrefslogtreecommitdiffhomepage
path: root/templates/settings_field.php
blob: 1ebbfb3259e970381a6446edbc40328b4cf96a34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
$id = "setting-$key";
$settingType = $type ?? 'text';
$inputType = $settingType;
if ($settingType == '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 ?>" autocomplete="off">
            <?php foreach ($options as $o): ?>
                <option <?= $value == $o ? 'selected' : '' ?>><?= $o ?></option>
            <?php endforeach; ?>
        </select>

    <?php elseif ($inputType == 'longtext'): ?>

        <textarea id="<?= $id ?>" name="<?= $fieldName ?>" autocomplete="off"><?= $value ?></textarea>

    <?php else: ?>

        <input id="<?= $id ?>" name="<?= $fieldName ?>" value="<?= $value ?>" type="<?= $inputType ?>" autocomplete="off">

    <?php endif; ?>
</div>