mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 08:09:18 +02:00
- Skip required-field validation for orientation/ap/finality/licence/jury in admin add+edit
50 lines
2.1 KiB
PHP
50 lines
2.1 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 ?? [];
|
|
$adminMode = $adminMode ?? false;
|
|
?>
|
|
<fieldset>
|
|
<legend>Cadre académique</legend>
|
|
|
|
<?php
|
|
$name = 'année'; $label = 'Année :'; $value = $oldFn('année'); $required = !$adminMode;
|
|
$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 = !$adminMode; $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 = !$adminMode; $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 = !$adminMode; $placeholder = '';
|
|
$attrs = $withAutofocusFn('finality');
|
|
include APP_ROOT . '/templates/partials/form/select-field.php';
|
|
?>
|
|
</fieldset>
|
|
<?php
|