Files
andreandClaude Sonnet 5 22dc14c8c8 refactor(equipa): partilhar _form.php entre create e edit (audit 6.8)
create.php e edit.php tinham os mesmos campos de formulário duplicados
lado a lado. Extrai o markup comum (nome, nascimento, área, estado,
foto, título, aptidões, formações, descrição) para _form.php, seguindo
o padrão já usado em events/ e memberships/. Cada view fica só com a
lógica que lhe é própria (criar vs. carregar registo existente,
upload/validação de foto, título da página, redirect).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-25 21:45:14 +01:00

42 lines
3.2 KiB
PHP

<?php
// Shared team-member form fields, rendered inside the <form> of both create.php and
// edit.php. Expects:
// $data : associative array with every team column (name, birthday, at, status,
// description, title, skills, certifications)
// $item : the existing row on edit (for the current photo preview), or null
$item = $item ?? null;
?>
<div class="row g-3">
<div class="col-md-8"><label class="form-label">Nome <span class="text-danger">*</span></label>
<input class="form-control" name="name" required value="<?= htmlspecialchars($data['name'] ?? '') ?>"></div>
<div class="col-md-4"><label class="form-label">Nascimento</label>
<input type="date" class="form-control" name="birthday" value="<?= htmlspecialchars($data['birthday'] ?? '') ?>"></div>
<div class="col-md-4"><label class="form-label">Área</label>
<select class="form-select" name="at"><option value="">—</option>
<option value="gym" <?= ($data['at'] ?? '') === 'gym' ? 'selected' : '' ?>>Gym</option>
<option value="crossfit" <?= ($data['at'] ?? '') === 'crossfit' ? 'selected' : '' ?>>CrossFit</option>
</select></div>
<div class="col-md-4"><label class="form-label">Estado</label>
<select class="form-select" name="status">
<option value="ativo" <?= ($data['status'] ?? '') === 'ativo' ? 'selected' : '' ?>>Ativo</option>
<option value="inativo" <?= ($data['status'] ?? '') === 'inativo' ? 'selected' : '' ?>>Inativo</option>
</select></div>
<div class="col-md-4">
<label class="form-label">Foto</label>
<?php if ($item && !empty($item['photo'])): ?>
<div class="mb-2"><img src="<?= base_url('uploads/team/foto/' . $item['photo']) ?>" alt="" style="max-height:80px;border-radius:4px;"></div>
<?php endif; ?>
<input type="file" class="form-control" name="photo" accept=".jpg,.jpeg,.png,.gif,.webp">
</div>
<div class="col-12"><label class="form-label">Título</label>
<input class="form-control" name="title" maxlength="100" placeholder="ex.: Personal Trainer · Coach CrossFit" value="<?= htmlspecialchars($data['title'] ?? '') ?>">
<div class="form-text">Aparece no site por baixo do nome.</div></div>
<div class="col-md-6"><label class="form-label">Aptidões / Funções</label>
<textarea class="form-control" name="skills" rows="5" placeholder="Uma por linha"><?= htmlspecialchars($data['skills'] ?? '') ?></textarea></div>
<div class="col-md-6"><label class="form-label">Formações</label>
<textarea class="form-control" name="certifications" rows="5" placeholder="Uma por linha"><?= htmlspecialchars($data['certifications'] ?? '') ?></textarea></div>
<div class="col-12"><div class="form-text mt-0">Aptidões e formações aparecem no cartão de detalhe do site (hover no computador, toque no telemóvel).</div></div>
<div class="col-12"><label class="form-label">Descrição <span class="text-muted small">(opcional — aparece no cartão de detalhe)</span></label>
<textarea class="form-control js-wysiwyg" data-wysiwyg-height="200" name="description" rows="3"><?= htmlspecialchars($data['description'] ?? '') ?></textarea></div>
</div>