edit.php

Code Hygiene Score: 100

Keine Issues gefunden.

Versionen 1

Code

<?php

declare(strict_types=1);

// @responsibility: View für Relation 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/relationen">Relationen</a> &raquo; Bearbeiten
</nav>

<h1>Relation bearbeiten</h1>
<p><?= htmlspecialchars($relation['source_name']) ?> &rarr; <?= htmlspecialchars($relation['target_name']) ?></p>

<form id="relation-form" class="form" style="max-width: 600px;"
      hx-post="/semantic-explorer/relationen/<?= $relation['id'] ?>"
      hx-headers='{"X-CSRF-TOKEN": "<?= $csrfToken ?>"}'
      hx-disabled-elt="button[type=submit]">
    <div class="form-group">
        <label for="relation_type">Beziehungstyp *</label>
        <select id="relation_type" name="relation_type" class="form-select" required>
            <?php foreach ($relationTypes as $t): ?>
            <option value="<?= htmlspecialchars($t) ?>"
                <?= $relation['relation_type'] === $t ? 'selected' : '' ?>><?= htmlspecialchars($t) ?></option>
            <?php endforeach; ?>
        </select>
    </div>

    <div class="form-group">
        <label for="strength">Staerke (0.0 - 1.0)</label>
        <input type="number" id="strength" name="strength" class="form-input"
               min="0" max="1" step="0.1" value="<?= htmlspecialchars((string)$relation['strength']) ?>">
    </div>

    <div class="form-actions">
        <button type="submit" class="btn btn--primary">Speichern</button>
        <a href="/semantic-explorer/relationen" class="btn">Abbrechen</a>
        <button type="button"
                class="btn btn--danger"
                style="margin-left: auto;"
                hx-post="/semantic-explorer/relationen/<?= $relation['id'] ?>/delete"
                hx-headers='{"X-CSRF-TOKEN": "<?= $csrfToken ?>"}'
                hx-confirm="Relation wirklich loeschen?"
                hx-disabled-elt="this">
            Loeschen
        </button>
    </div>
</form>

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