Fixes configfile edit form

main
Yasen Pramatarov 2024-10-29 13:45:27 +02:00
parent 82962e0449
commit a953dd386d
2 changed files with 4 additions and 14 deletions

View File

@ -47,30 +47,20 @@ function editConfig($configPart, $indent, $platform=false, $parent='') {
<?php foreach ($configPart as $config_item => $config_value) { ?> <?php foreach ($configPart as $config_item => $config_value) { ?>
<div class="row mb-1" style="padding-left: <?= $indent ?>px;"> <div class="row mb-1" style="padding-left: <?= $indent ?>px;">
<div class="col-md-4 text-end"> <div class="col-md-4 text-end">
<?= htmlspecialchars($config_item) ?>:
<label for="<?= htmlspecialchars($config_item) ?>" class="form-label"><?= htmlspecialchars($config_item) ?></label> <label for="<?= htmlspecialchars($config_item) ?>" class="form-label"><?= htmlspecialchars($config_item) ?></label>
<span class="text-danger" style="margin-right: -12px;">*</span>
</div> </div>
<?php <?php
if (is_array($config_value)) { if (is_array($config_value)) {
// here we render recursively nested arrays // here we render recursively nested arrays
$indent = $indent + 50; $indent = $indent + 50;
if ($parent === 'platforms') {
$indent = 100;
}
if ($config_item === 'platforms') {
editConfig($config_value, $indent, $platform, 'platforms');
} else {
editConfig($config_value, $indent, $platform); editConfig($config_value, $indent, $platform);
}
$indent = 0; $indent = 0;
} else { } else {
// if it's not array, just display it // if it's not array, just display it
?> ?>
<div class="border col-md-8 text-start"> <div class="col-md-8 text-start">
<?= htmlspecialchars($config_value ?? '')?> <input class="form-control" type="text" name="<?= htmlspecialchars($config_item) ?>" value="<?= htmlspecialchars($config_value ?? '') ?>" required autofocus />
<input class="form-control" type="text" name="<?= htmlspecialchars($config_value) ?>" value="<?= htmlspecialchars($config_value ?? '') ?>" required autofocus />
</div> </div>
<?php } ?> <?php } ?>
</div> </div>

View File

@ -13,7 +13,7 @@ echo "\n";
?> ?>
<br /> <br />
<a class="btn btn-secondary" href="<?= htmlspecialchars($app_root) ?>?page=config#platform<?= htmlspecialchars($platform_id) ?>" />Cancel</a> <a class="btn btn-secondary" href="<?= htmlspecialchars($app_root) ?>?page=config&item=config_file" />Cancel</a>
<input type="submit" class="btn btn-primary" value="Save" /> <input type="submit" class="btn btn-primary" value="Save" />
</form> </form>