<?php $fieldItem = $editingItem ?? []; ?>
<div class="form-grid">
    <label class="span-2">Name<input type="text" name="name" required placeholder="Internet, rent, groceries…" value="<?= h($fieldItem['name'] ?? '') ?>"></label>
    <label>Target amount<div class="money-input"><span><?= h($symbol) ?></span><input type="number" name="planned_amount" min="0" step="0.01" required value="<?= h((string) ($fieldItem['planned_amount'] ?? '')) ?>"></div></label>
    <label>Category<select name="category_id"><option value="">Uncategorized</option><?php foreach ($categories as $category): ?><option value="<?= (int) $category['id'] ?>" <?= (int) ($fieldItem['category_id'] ?? 0) === (int) $category['id'] ? 'selected' : '' ?>><?= h($category['name']) ?></option><?php endforeach; ?></select></label>
    <label>Due date<input type="date" name="due_date" value="<?= h((string) ($fieldItem['due_date'] ?? $month . '-01')) ?>"></label>
    <label>Repeat<select name="recurrence"><option value="none" <?= ($fieldItem['recurrence'] ?? 'none') === 'none' ? 'selected' : '' ?>>One time</option><option value="monthly" <?= ($fieldItem['recurrence'] ?? '') === 'monthly' ? 'selected' : '' ?>>Monthly</option><option value="yearly" <?= ($fieldItem['recurrence'] ?? '') === 'yearly' ? 'selected' : '' ?>>Yearly</option></select></label>
    <label class="span-2">Notes<textarea name="notes" rows="2" placeholder="Optional details"><?= h($fieldItem['notes'] ?? '') ?></textarea></label>
</div>
