edit.php

Code Hygiene Score: 100

Keine Issues gefunden.

Versionen 1

Code

<?php

declare(strict_types=1);

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

ob_start();
?>

<nav class="breadcrumb">
    <a href="/tasks">Tasks</a> &raquo; <a href="/tasks/<?= $task['id'] ?>">Task #<?= $task['id'] ?></a> &raquo; Bearbeiten
</nav>

<h1>Task bearbeiten</h1>

<form id="task-form" class="form" style="max-width: 600px;"
      hx-put="/api/v1/tasks/<?= $task['id'] ?>"
      hx-headers='{"X-CSRF-TOKEN": "<?= $csrfToken ?>"}'
      hx-disabled-elt="button[type=submit]">
    <div class="form-group">
        <label for="title">Titel *</label>
        <input type="text" id="title" name="title" class="form-input" value="<?= htmlspecialchars($task['title']) ?>" required>
    </div>
    <div class="form-group">
        <label for="description">Beschreibung</label>
        <textarea id="description" name="description" class="form-textarea" rows="4"><?= htmlspecialchars($task['description'] ?? '') ?></textarea>
    </div>
    <div class="form-group">
        <label for="type">Typ</label>
        <select id="type" name="type" class="form-select">
            <option value="human_task" <?= $task['type'] === 'human_task' ? 'selected' : '' ?>>Mensch</option>
            <option value="ai_task" <?= $task['type'] === 'ai_task' ? 'selected' : '' ?>>KI</option>
            <option value="mixed" <?= $task['type'] === 'mixed' ? 'selected' : '' ?>>Gemischt</option>
        </select>
    </div>
    <div class="form-actions">
        <button type="submit" class="btn btn--primary">Speichern</button>
        <a href="/tasks/<?= $task['id'] ?>" class="btn">Abbrechen</a>
    </div>
</form>

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