<div class="header">
    <h1>Edit provider</h1>
</div>

<?php if (session('error')): ?>
<p class="error"><?= esc(session('error')) ?></p>
<?php endif ?>

<form method="post" action="<?= base_url('admin/providers/edit/' . $provider->id) ?>">
    <input type="hidden" name="<?= csrf_token() ?>" value="<?= csrf_hash() ?>">
    <p>
        <label>Name</label><br>
        <input type="text" name="name" value="<?= esc($provider->name) ?>" required>
    </p>
    <p>
        <label>Type</label><br>
        <select name="provider_type">
            <option value="fuel" <?= ($provider->provider_type ?? '') === 'fuel' ? 'selected' : '' ?>>Fuel</option>
            <option value="gas" <?= ($provider->provider_type ?? '') === 'gas' ? 'selected' : '' ?>>Gas</option>
        </select>
    </p>
    <p>
        <button type="submit" class="btn btn-primary">Save</button>
        <a href="<?= base_url('admin/providers') ?>" class="btn btn-secondary">Cancel</a>
    </p>
</form>
