Fix form field required states & missing fields per spec

- Admin add: add contact_public checkbox (matching edit form)
- All forms: formats checkbox-list now required
- All forms: jury promoteur·ice interne required, lecteur·ice interne/externe required
- All forms: licence select now required
- Admin edit: add E-mail de confirmation fieldset
- Partage: contact always visible when provided (no contact_public field)
- Partage: filter PACS from AP programs dropdown
- Server-side validation: formats, jury, licence required (create + edit controllers)
- Autofocus mappings for new validation errors
- No duplicate asterisks — verified across all rendered fields
- fix: add missing old() function in admin edit controller
- refactor: move admin email field to Backoffice as Contact interne, never send email
- Untrack admin.log (covered by .gitignore)
This commit is contained in:
Pontoporeia
2026-05-07 19:54:52 +02:00
parent 51f9f56e09
commit 696259afae
11 changed files with 307 additions and 45 deletions

View File

@@ -16,6 +16,19 @@
include APP_ROOT . '/templates/partials/form/fieldset-tfe-info.php';
?>
<!-- ═══════════════════ Contact ═══════════════════ -->
<fieldset>
<legend>Contact</legend>
<div class="admin-form-group">
<label class="admin-checkbox-label">
<input type="checkbox" name="contact_public" value="1"
<?= !empty($formData['contact_public']) ? 'checked' : '' ?>>
Rendre le contact visible publiquement sur la fiche du TFE
</label>
<small>L'adresse est toujours conservée en interne comme contact de référence.</small>
</div>
</fieldset>
<!-- ═══════════════════ Langue(s) ═══════════════════ -->
<fieldset>
<legend>Langue(s)</legend>
@@ -26,7 +39,7 @@
<!-- ═══════════════════ Format(s) ═══════════════════ -->
<fieldset>
<legend>Format(s)</legend>
<?php $name = 'formats'; $label = 'Format(s) du TFE :'; $options = $formatTypes; $checked = $formData['formats'] ?? []; include APP_ROOT . '/templates/partials/form/checkbox-list.php'; ?>
<?php $name = 'formats'; $label = 'Format(s) du TFE :'; $options = $formatTypes; $checked = $formData['formats'] ?? []; $required = true; include APP_ROOT . '/templates/partials/form/checkbox-list.php'; ?>
</fieldset>
<!-- ═══════════════════ Mots-clés ═══════════════════ -->
@@ -82,10 +95,62 @@
include APP_ROOT . '/templates/partials/form/fieldset-licence-explanation.php';
?>
<!-- ═══════════════════ E-mail de confirmation ═══════════════ -->
<!-- ═══════════════════ Note contextuelle ═══════════════════ -->
<fieldset>
<legend>E-mail de confirmation</legend>
<?php $name = 'confirmation_email'; $label = 'Adresse e-mail :'; $value = old('confirmation_email'); $type = 'email'; $required = false; $placeholder = 'ton.email@exemple.be'; $hint = 'Optionnel — pour envoyer un récapitulatif de la soumission.'; $attrs = withAutofocus('confirmation_email'); include APP_ROOT . '/templates/partials/form/text-field.php'; ?>
<legend>Note contextuelle</legend>
<div>
<label for="context_note">Note contextuelle :</label>
<div>
<textarea id="context_note" name="context_note"
rows="4" maxlength="1500"><?= htmlspecialchars($formData['context_note'] ?? '') ?></textarea>
<small>Visible publiquement pour les TFE Interne ou Interdit. Max 1 500 caractères.</small>
</div>
</div>
</fieldset>
<!-- ═══════════════════ Backoffice ═══════════════════ -->
<fieldset>
<legend>Backoffice</legend>
<div class="admin-form-group">
<label for="jury_points">Points :</label>
<input type="number" id="jury_points" name="jury_points"
value="<?= htmlspecialchars($formData['jury_points'] ?? '') ?>"
step="0.01" min="0" max="20" placeholder="sur 20">
<small>Note du jury (interne, non visible publiquement).</small>
</div>
<div class="admin-form-group">
<label for="remarks">Remarques :</label>
<textarea id="remarks" name="remarks" rows="4"><?= htmlspecialchars($formData['remarks'] ?? '') ?></textarea>
<small>Notes internes (non visibles publiquement).</small>
</div>
<div class="admin-form-group">
<label for="contact_interne">Contact interne :</label>
<input type="email" id="contact_interne" name="contact_interne"
value="<?= htmlspecialchars($formData['contact_interne'] ?? '') ?>"
placeholder="ton.email@exemple.be">
<small>Adresse de contact interne (non visible publiquement).</small>
</div>
<div class="admin-form-group">
<label class="admin-checkbox-label">
<input type="checkbox" name="exemplaire_baiu" value="1"
<?= !empty($formData['exemplaire_baiu']) ? 'checked' : '' ?>>
Exemplaire physique BAIU
</label>
<small>Case logistique : cocher si un exemplaire physique est disponible à la BAIU.</small>
</div>
<div class="admin-form-group">
<label class="admin-checkbox-label">
<input type="checkbox" name="exemplaire_erg" value="1"
<?= !empty($formData['exemplaire_erg']) ? 'checked' : '' ?>>
Exemplaire physique ERG
</label>
<small>Case logistique : cocher si un exemplaire physique est disponible à l'ERG.</small>
</div>
</fieldset>
<div class="form-footer">

View File

@@ -65,7 +65,7 @@
<legend>Format(s)</legend>
<?php
$checkedFormats = $formData['formats'] ?? $currentFormats;
$name = 'formats'; $label = 'Format(s) du TFE :'; $options = $formatTypes; $checked = $checkedFormats;
$name = 'formats'; $label = 'Format(s) du TFE :'; $options = $formatTypes; $checked = $checkedFormats; $required = true;
include APP_ROOT . '/templates/partials/form/checkbox-list.php';
?>
</fieldset>
@@ -301,6 +301,14 @@
<small>Notes internes (non visibles publiquement).</small>
</div>
<div class="admin-form-group">
<label for="contact_interne">Contact interne :</label>
<input type="email" id="contact_interne" name="contact_interne"
value="<?= htmlspecialchars($currentRaw['contact_interne'] ?? $currentAuthorEmail ?? '') ?>"
placeholder="ton.email@exemple.be">
<small>Adresse de contact interne (non visible publiquement).</small>
</div>
<div class="admin-form-group">
<label class="admin-checkbox-label">
<input type="checkbox" name="exemplaire_baiu" value="1"

View File

@@ -88,7 +88,7 @@ $defaultAccessTypeId = $defaultAccessTypeId ?? 2;
<h3>Licence du TFE</h3>
<?php
$name = 'license_id'; $label = 'Licence :'; $options = $licenseTypes;
$selected = $formData['license_id'] ?? ''; $placeholder = '— Sélectionner —';
$selected = $formData['license_id'] ?? ''; $placeholder = '— Sélectionner —'; $required = true;
include APP_ROOT . '/templates/partials/form/select-field.php';
?>

View File

@@ -45,9 +45,9 @@ if ($addMode && function_exists('old')) {
<!-- Promoteur·ice interne -->
<div>
<label for="jury_promoteur">Promoteur·ice interne :</label>
<label for="jury_promoteur">Promoteur·ice interne : <span class="asterisk">*</span></label>
<input type="text" id="jury_promoteur" name="jury_promoteur"
value="<?= htmlspecialchars($juryPromoteur ?? '') ?>" placeholder="Nom">
value="<?= htmlspecialchars($juryPromoteur ?? '') ?>" placeholder="Nom" required>
</div>
<?php if ($showPromoteurUlb): ?>
@@ -86,11 +86,11 @@ if ($addMode && function_exists('old')) {
<!-- Lecteur·ice(s) interne -->
<fieldset class="admin-jury-lecteurs">
<legend>Lecteur·ice(s) interne</legend>
<legend>Lecteur·ice(s) interne <span class="asterisk">*</span></legend>
<div id="jury-lecteurs-internes-list" class="admin-jury-list">
<?php if (empty($lecteursInternes)): ?>
<div class="admin-jury-entry">
<input type="text" name="jury_lecteur_interne[]" placeholder="Nom"
<input type="text" name="jury_lecteur_interne[]" placeholder="Nom" required
aria-label="Lecteur·ice interne 1 — nom">
<button type="button" class="btn btn--sm btn--ghost admin-btn-remove"
onclick="removeJuryRow(this)" aria-label="Supprimer"><span aria-hidden="true">✕</span></button>
@@ -100,6 +100,7 @@ if ($addMode && function_exists('old')) {
<div class="admin-jury-entry">
<input type="text" name="jury_lecteur_interne[]"
value="<?= htmlspecialchars($lm['name']) ?>" placeholder="Nom"
<?= $li === 0 ? 'required' : '' ?>
aria-label="Lecteur·ice interne <?= $li + 1 ?> — nom">
<button type="button" class="btn btn--sm btn--ghost admin-btn-remove"
onclick="removeJuryRow(this)" aria-label="Supprimer"><span aria-hidden="true">✕</span></button>
@@ -115,11 +116,11 @@ if ($addMode && function_exists('old')) {
<!-- Lecteur·ice(s) externe -->
<fieldset class="admin-jury-lecteurs">
<legend>Lecteur·ice(s) externe</legend>
<legend>Lecteur·ice(s) externe <span class="asterisk">*</span></legend>
<div id="jury-lecteurs-externes-list" class="admin-jury-list">
<?php if (empty($lecteursExternes)): ?>
<div class="admin-jury-entry">
<input type="text" name="jury_lecteur_externe[]" placeholder="Nom"
<input type="text" name="jury_lecteur_externe[]" placeholder="Nom" required
aria-label="Lecteur·ice externe 1 — nom">
<button type="button" class="btn btn--sm btn--ghost admin-btn-remove"
onclick="removeJuryRow(this)" aria-label="Supprimer"><span aria-hidden="true">✕</span></button>
@@ -129,6 +130,7 @@ if ($addMode && function_exists('old')) {
<div class="admin-jury-entry">
<input type="text" name="jury_lecteur_externe[]"
value="<?= htmlspecialchars($lm['name']) ?>" placeholder="Nom"
<?= $li === 0 ? 'required' : '' ?>
aria-label="Lecteur·ice externe <?= $li + 1 ?> — nom">
<button type="button" class="btn btn--sm btn--ghost admin-btn-remove"
onclick="removeJuryRow(this)" aria-label="Supprimer"><span aria-hidden="true">✕</span></button>