partage: lock Année field to link's locked_year when present

When a student-access share link specifies a locked_year, the Année field
in the student-facing form is now pre-filled with that year and rendered
as disabled+readonly, with a hidden input ensuring the value is submitted.

- renderShareLinkForm() exposes  from ['locked_year']
- fieldset-academic.php checks for : if set, outputs a hidden
  input plus the visible field locked to that value; otherwise falls back
  to the normal editable field
This commit is contained in:
Pontoporeia
2026-07-08 13:50:03 +02:00
parent a3953800a4
commit f9d8fab120
2 changed files with 20 additions and 1 deletions
@@ -15,15 +15,30 @@ $oldFn = $oldFn ?? (function_exists('old') ? 'old' : fn($k,
$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 :'; $value = $oldFn('année'); $required = !$adminMode;
$name = 'année'; $label = 'Année :';
$required = !$adminMode;
$type = 'number';
$placeholder = date('Y');
$attrs = $withAutofocusFn('année', ['min' => 2000, 'max' => date('Y') + 1]);
if ($lockedYear !== null):
// Link specifies a locked academic year: pre-fill, disable editing.
$value = (string)$lockedYear;
$attrs['disabled'] = true;
$attrs['readonly'] = true;
// Include a hidden input so the value is still submitted when the field is disabled.
?>
<input type="hidden" name="année" value="<?= htmlspecialchars((string)$lockedYear) ?>">
<?php
else:
$value = $oldFn('année');
endif;
include APP_ROOT . '/templates/partials/form/text-field.php';
?>