new.php

Code Hygiene Score: 100

Keine Issues gefunden.

Versionen 1

Code

<?php

declare(strict_types=1);

// @responsibility: View für neuen Taxonomie-Begriff 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; Neu
</nav>

<h1>Neuer Taxonomie-Begriff</h1>

<form id="taxonomy-form" class="form" style="max-width: 600px;"
      hx-post="/semantic-explorer/taxonomie"
      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>
    </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): ?>
            <option value="<?= $t['id'] ?>">
                <?= str_repeat('&nbsp;&nbsp;', $t['depth']) ?><?= htmlspecialchars($t['name']) ?>
            </option>
            <?php endforeach; ?>
        </select>
    </div>

    <div class="form-actions">
        <button type="submit" class="btn btn--primary">Begriff erstellen</button>
        <a href="/semantic-explorer/taxonomie" class="btn">Abbrechen</a>
    </div>
</form>

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