new.php

Code Hygiene Score: 100

Keine Issues gefunden.

Versionen 4

Code

<?php

declare(strict_types=1);

// @responsibility: View für neue Relation 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; Neu
</nav>

<h1>Neue Relation</h1>

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

    <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) ?>"><?= htmlspecialchars($t) ?></option>
            <?php endforeach; ?>
        </select>
    </div>

    <div class="form-group">
        <label for="target_entity_id">Ziel-Entitaet *</label>
        <select id="target_entity_id" name="target_entity_id" class="form-select" required>
            <option value="">-- Bitte waehlen --</option>
            <?php foreach ($entities as $e): ?>
            <option value="<?= $e['id'] ?>"><?= htmlspecialchars($e['name']) ?> (<?= $e['type'] ?>)</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="1.0">
    </div>

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

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