<?php

declare(strict_types=1);

require_once __DIR__ . '/helpers.php';

club_module_boot();

$clubRecord = find_club_or_abort((int) ($_GET['id'] ?? 0));
$pageTitle = 'Edit Club';
$formErrors = flash('errors') ?? [];

require dirname(__DIR__, 2) . '/includes/header.php';
require dirname(__DIR__, 2) . '/includes/sidebar.php';
require dirname(__DIR__, 2) . '/includes/topbar.php';
require dirname(__DIR__, 2) . '/includes/flash.php';
?>
<section class="panel-card">
    <div class="panel-card-header mb-3">
        <div>
            <p class="eyebrow mb-1">Clubs</p>
            <h2 class="h4 mb-0">Edit club</h2>
        </div>
    </div>
    <form method="post" action="<?php echo e(base_url('app/modules/clubs/actions.php')); ?>" enctype="multipart/form-data">
        <?php echo csrf_input(); ?>
        <input type="hidden" name="action" value="update">
        <input type="hidden" name="id" value="<?php echo e((string) $clubRecord['id']); ?>">
        <?php require __DIR__ . '/_form.php'; ?>
        <div class="d-flex gap-2 mt-4"><button class="btn btn-jlfc" type="submit">Save changes</button><a class="btn btn-light" href="<?php echo e(base_url('app/modules/clubs/view.php?id=' . (int) $clubRecord['id'])); ?>">Back</a></div>
    </form>
</section>
<?php clear_old_input(); ?>
<?php require dirname(__DIR__, 2) . '/includes/footer.php'; ?>