Files
xamxam/app/templates/partials/form/fieldset-academic.php
Pontoporeia bdd95341b0 Extract shared TFE form partial — single source of truth for add/edit/partage
Created templates/partials/form/form.php as the unified form template driven by
$mode ('add'|'edit'|'partage') and boolean flags for optional sections.

The three calling templates (templates/admin/add.php, templates/admin/edit.php,
partage/index.php renderShareLinkForm) now only set variables then include the
shared partial. ~200 lines of duplicated fieldset HTML eliminated.
2026-05-07 23:39:41 +02:00

49 lines
2.0 KiB
PHP

<?php
/**
* Shared partial — "Cadre académique" fieldset.
*
* Variables consumed:
* callable|null $oldFn — callable($key, $default='') for old/current values.
* callable|null $withAutofocusFn — callable($field, $attrs=[]) to inject autofocus.
* array $orientations — options for the orientation select.
* array $apPrograms — options for the AP select.
* array $finalityTypes — options for the finality select.
* array $formData — raw form data (used for selected state).
*/
$oldFn = $oldFn ?? (function_exists('old') ? 'old' : fn($k, $d = '') => $d);
$withAutofocusFn = $withAutofocusFn ?? fn($field, $attrs = []) => $attrs;
$formData = $formData ?? [];
?>
<fieldset>
<legend>Cadre académique</legend>
<?php
$name = 'année'; $label = 'Année :'; $value = $oldFn('année'); $required = true;
$type = 'number';
$placeholder = date('Y');
$attrs = $withAutofocusFn('année', ['min' => 2000, 'max' => date('Y') + 1]);
include APP_ROOT . '/templates/partials/form/text-field.php';
?>
<?php
$name = 'orientation'; $label = 'Orientation :'; $options = $orientations;
$selected = $formData['orientation'] ?? ''; $required = true; $placeholder = '';
$attrs = $withAutofocusFn('orientation');
include APP_ROOT . '/templates/partials/form/select-field.php';
?>
<?php
$name = 'ap'; $label = 'Atelier pluridisciplinaire :'; $options = $apPrograms;
$selected = $formData['ap'] ?? ''; $required = true; $placeholder = '';
$attrs = $withAutofocusFn('ap');
include APP_ROOT . '/templates/partials/form/select-field.php';
?>
<?php
$name = 'finality'; $label = 'Finalité du master :'; $options = $finalityTypes;
$selected = $formData['finality'] ?? ''; $required = true; $placeholder = '';
$attrs = $withAutofocusFn('finality');
include APP_ROOT . '/templates/partials/form/select-field.php';
?>
</fieldset>
<?php