aboutsummaryrefslogtreecommitdiffhomepage
path: root/templates/settings_field.php
blob: c0f0f7d20306c066bba0a59dd87f893b11d1e6ef (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
<?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 ?>" autocomplete="off">
            <?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>