Files
xamxam/app/templates/partials/form/fieldset-academic.php
T
Pontoporeia 6ecab96137 fieldset-academic: dim locked year field, remove required asterisk
When locked_year is set, render the Année label+input inline with
opacity:0.55 instead of via text-field.php. No asterisk since editing
is disabled. The hidden input still ensures the value is submitted.
2026-07-08 13:50:03 +02:00

70 lines
2.8 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;
$lockedYear = $lockedYear ?? null;
?>
<fieldset>
<legend>Cadre académique</legend>
<?php
$name = 'année'; $label = 'Année :';
$type = 'number';
$placeholder = date('Y');
if ($lockedYear !== null):
// Link specifies a locked academic year: render a dimmed, non-editable
// field with no required indicator, plus a hidden input for submission.
?>
<input type="hidden" name="année" value="<?= htmlspecialchars((string)$lockedYear) ?>">
<div style="opacity:0.55">
<label for="année"><?= htmlspecialchars($label) ?></label>
<input type="number" id="année"
value="<?= htmlspecialchars((string)$lockedYear) ?>"
disabled readonly
min="2000" max="<?= date('Y') + 1 ?>"
placeholder="<?= htmlspecialchars($placeholder) ?>">
</div>
<?php
else:
$required = !$adminMode;
$value = $oldFn('année');
$attrs = $withAutofocusFn('année', ['min' => 2000, 'max' => date('Y') + 1]);
include APP_ROOT . '/templates/partials/form/text-field.php';
endif;
?>
<?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