From 10b07393fea4bbda7f316aab5cc05491e7eb83c4 Mon Sep 17 00:00:00 2001 From: Pontoporeia Date: Thu, 2 Apr 2026 12:26:44 +0200 Subject: [PATCH] Extract jury-fieldset.php partial; deduplicate jury section from add.php and edit.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The jury composition fieldset (président·e, promoteur·ice + external checkbox, dynamic lecteur·ices list with JS add/remove) was copy-pasted verbatim between the two longest admin forms. - Created templates/partials/form/jury-fieldset.php - Consumes $juryPresident, $juryPromoteur, $juryPromoteurExt, $juryLecteurs[] - Handles both add-mode (falls back to old()/wasSelected() flash helpers) and edit-mode (pre-populates from DB-loaded variables) - $juryIdx initialised from max(count($juryLecteurs), 1) — correct for both modes - add.php: 311 → 251 lines (-60); entire fieldset + +
diff --git a/public/admin/edit.php b/public/admin/edit.php index 9a4e8f9..d5b753b 100644 --- a/public/admin/edit.php +++ b/public/admin/edit.php @@ -148,77 +148,7 @@ try { } } ?> -
- Composition du jury - -
- - -
- -
- -
- - -
-
- -
- -
-
- -
- - - -
- - $lm): ?> -
- - - -
- - -
- -
-
-
- +
diff --git a/templates/partials/form/jury-fieldset.php b/templates/partials/form/jury-fieldset.php new file mode 100644 index 0000000..bfc2eea --- /dev/null +++ b/templates/partials/form/jury-fieldset.php @@ -0,0 +1,107 @@ + string, 'is_external' => int] + * + * In "add" mode (no existing jury data), callers should pass nulls/empty arrays and + * may rely on the $formData repopulation helpers (old/wasSelected) defined in add.php. + * When those helpers exist and no explicit values are set, the partial uses them. + */ + +$juryPresident = $juryPresident ?? null; +$juryPromoteur = $juryPromoteur ?? null; +$juryPromoteurExt = $juryPromoteurExt ?? 0; +$juryLecteurs = $juryLecteurs ?? []; + +// In add-mode, repopulate from flash form data when helpers are available. +$addMode = ($juryPresident === null && $juryPromoteur === null && empty($juryLecteurs)); +if ($addMode && function_exists('old')) { + $juryPresident = old('jury_president') ?: null; + $juryPromoteur = old('jury_promoteur') ?: null; + $juryPromoteurExt = function_exists('wasSelected') && wasSelected('jury_promoteur_ext', '1') ? 1 : 0; +} + +$juryIdx = max(count($juryLecteurs), 1); +?> + +
+ Composition du jury + + +
+ + +
+ + +
+ +
+ + +
+
+ + +
+ +
+
+ +
+ + + +
+ + $lm): ?> +
+ + + +
+ + +
+ +
+
+
+