mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-07 11:39:18 +02:00
fieldset-academic.php, fieldset-metadata.php and fieldset-licence-explanation.php were each calling unset($formData) (or wrong variable) in their cleanup block, destroying the variable in the parent renderShareLinkForm() scope. This caused an Undefined variable / TypeError on old($formData, ...) for any field rendered after those partials (e.g. confirmation_email at line 328). Fix: remove $formData from the unset() calls; fieldset-licence-explanation.php was also unsetting the wrong name — corrected to unset($n) which is the variable it actually declares.
63 lines
2.9 KiB
PHP
63 lines
2.9 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 $languages — options for the language checkbox list.
|
|
* array $formatTypes — options for the format checkbox list.
|
|
* array $formData — raw form data (used for checkbox checked 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';
|
|
?>
|
|
|
|
<?php $name = 'languages'; $label = 'Langue(s) :'; $options = $languages; $checked = $formData['languages'] ?? []; $required = true; include APP_ROOT . '/templates/partials/form/checkbox-list.php'; ?>
|
|
<?php $name = 'formats'; $label = 'Format(s) :'; $options = $formatTypes; $checked = $formData['formats'] ?? []; include APP_ROOT . '/templates/partials/form/checkbox-list.php'; ?>
|
|
|
|
<?php
|
|
$name = 'tag'; $label = 'Mots-clés :'; $value = $oldFn('tag');
|
|
$placeholder = 'sociologie, anthropologie, ...';
|
|
$hint = 'Séparez par des virgules. Max 10 mots-clés.';
|
|
$attrs = $withAutofocusFn('tag');
|
|
include APP_ROOT . '/templates/partials/form/text-field.php';
|
|
?>
|
|
</fieldset>
|
|
<?php
|
|
unset($oldFn, $withAutofocusFn);
|