edit.php

Code Hygiene Score: 100

Keine Issues gefunden.

Versionen 1

Code

<?php

declare(strict_types=1);

// @responsibility: View für Taxonomie-Begriff bearbeiten mit HTMX-Formular

ob_start();
?>

<nav class="breadcrumb">
    <a href="/">Campus KI</a> &raquo;
    <a href="/semantic-explorer">Semantic Explorer</a> &raquo;
    <a href="/semantic-explorer/taxonomie">Taxonomie</a> &raquo; <?= htmlspecialchars($term['name']) ?> &raquo; Bearbeiten
</nav>

<h1>Taxonomie-Begriff bearbeiten</h1>

<form id="taxonomy-form" class="form" style="max-width: 600px;"
      hx-post="/semantic-explorer/taxonomie/<?= $term['id'] ?>"
      hx-headers='{"X-CSRF-TOKEN": "<?= $csrfToken ?>"}'
      hx-disabled-elt="button[type=submit]">
    <div class="form-group">
        <label for="name">Name *</label>
        <input type="text" id="name" name="name" class="form-input" required
               value="<?= htmlspecialchars($term['name']) ?>">
    </div>

    <div class="form-group">
        <label for="parent_id">Uebergeordneter Begriff</label>
        <select id="parent_id" name="parent_id" class="form-select">
            <option value="">-- Kein (Root-Element) --</option>
            <?php foreach ($terms as $t): ?>
            <?php if ($t['id'] !== $term['id']): ?>
            <option value="<?= $t['id'] ?>"
                <?= ($term['parent_id'] ?? '') == $t['id'] ? 'selected' : '' ?>>
                <?= str_repeat('&nbsp;&nbsp;', $t['depth']) ?><?= htmlspecialchars($t['name']) ?>
            </option>
            <?php endif; ?>
            <?php endforeach; ?>
        </select>
    </div>

    <div class="form-actions">
        <button type="submit" class="btn btn--primary">Speichern</button>
        <a href="/semantic-explorer/taxonomie" class="btn">Abbrechen</a>
        <button type="button"
                class="btn btn--danger"
                style="margin-left: auto;"
                hx-post="/semantic-explorer/taxonomie/<?= $term['id'] ?>/delete"
                hx-headers='{"X-CSRF-TOKEN": "<?= $csrfToken ?>"}'
                hx-confirm="Begriff wirklich loeschen? Untergeordnete Begriffe muessen zuerst geloescht werden."
                hx-disabled-elt="this">
            Loeschen
        </button>
    </div>
</form>

<?php $content = ob_get_clean(); ?>
<?php require VIEW_PATH . '/layout.php'; ?>
← Übersicht