<form method="post" action="<?= e($action) ?>" class="form-grid">
    <?= csrf_field() ?>
    <?php if (!empty($broker['id'])): ?>
        <input type="hidden" name="id" value="<?= e((string) $broker['id']) ?>">
    <?php endif; ?>

    <label>
        <span>Company Name *</span>
        <input name="company_name" value="<?= e(old('company_name', $broker['company_name'] ?? '')) ?>" required>
    </label>
    <label>
        <span>Contact Name</span>
        <input name="contact_name" value="<?= e(old('contact_name', $broker['contact_name'] ?? '')) ?>">
    </label>
    <label>
        <span>Email</span>
        <input type="email" name="email" value="<?= e(old('email', $broker['email'] ?? '')) ?>">
    </label>
    <label>
        <span>Phone</span>
        <input name="phone" value="<?= e(old('phone', $broker['phone'] ?? '')) ?>">
    </label>
    <label>
        <span>MC Number</span>
        <input name="mc_number" value="<?= e(old('mc_number', $broker['mc_number'] ?? '')) ?>">
    </label>
    <label>
        <span>Payment Terms</span>
        <input name="payment_terms" value="<?= e(old('payment_terms', $broker['payment_terms'] ?? 'Net 30')) ?>">
    </label>
    <label>
        <span>Status</span>
        <select name="status">
            <?php foreach (['active', 'inactive'] as $status): ?>
                <option value="<?= e($status) ?>" <?= old('status', $broker['status'] ?? 'active') === $status ? 'selected' : '' ?>><?= e(readable_status($status)) ?></option>
            <?php endforeach; ?>
        </select>
    </label>
    <label class="span-2">
        <span>Address</span>
        <input name="address" value="<?= e(old('address', $broker['address'] ?? '')) ?>">
    </label>

    <div class="form-actions span-2">
        <button class="btn btn-primary" type="submit">Save Broker</button>
        <a class="btn btn-light" href="<?= url('/brokers') ?>">Cancel</a>
    </div>
</form>
