mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 19:19:19 +02:00
centralise form fieldsets into shared partials; add TODO stubs in partage form
This commit is contained in:
62
app/templates/partials/form/fieldset-academic.php
Normal file
62
app/templates/partials/form/fieldset-academic.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?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, $formData);
|
||||
Reference in New Issue
Block a user