mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
Created templates/partials/form/form.php as the unified form template driven by
$mode ('add'|'edit'|'partage') and boolean flags for optional sections.
The three calling templates (templates/admin/add.php, templates/admin/edit.php,
partage/index.php renderShareLinkForm) now only set variables then include the
shared partial. ~200 lines of duplicated fieldset HTML eliminated.
49 lines
1.8 KiB
PHP
49 lines
1.8 KiB
PHP
<?php
|
|
/**
|
|
* Shared partial — "Métadonnées complémentaires" fieldset.
|
|
*
|
|
* Now split: licence/access moved to licence-explanation fieldset.
|
|
* This fieldset keeps: duration (pages + minutes), lien (external link).
|
|
*
|
|
* Variables consumed:
|
|
* callable|null $oldFn — callable($key, $default='') for old/current values.
|
|
* callable|null $withAutofocusFn — callable($field, $attrs=[]) to inject autofocus.
|
|
* array $formData — raw form data (used for repopulation).
|
|
*/
|
|
|
|
$oldFn = $oldFn ?? (function_exists('old') ? 'old' : fn($k, $d = '') => $d);
|
|
$withAutofocusFn = $withAutofocusFn ?? fn($field, $attrs = []) => $attrs;
|
|
$formData = $formData ?? [];
|
|
?>
|
|
<fieldset>
|
|
<legend>Métadonnées complémentaires</legend>
|
|
|
|
<?php
|
|
$name = 'duration_pages'; $label = 'Nombre de pages :'; $value = $oldFn('duration_pages');
|
|
$type = 'number'; $placeholder = ''; $hint = 'Ex : 84';
|
|
include APP_ROOT . '/templates/partials/form/text-field.php';
|
|
?>
|
|
|
|
<?php
|
|
$name = 'duration_minutes'; $label = 'Durée (minutes) :'; $value = $oldFn('duration_minutes');
|
|
$type = 'number'; $placeholder = ''; $hint = 'Ex : 32 (pour œuvres audio/vidéo)';
|
|
include APP_ROOT . '/templates/partials/form/text-field.php';
|
|
?>
|
|
|
|
<div class="admin-form-group">
|
|
<label class="admin-checkbox-label">
|
|
<input type="checkbox" name="has_annexes" value="1"
|
|
<?= !empty($formData['has_annexes']) ? 'checked' : '' ?>>
|
|
Ce TFE comporte des annexes
|
|
</label>
|
|
</div>
|
|
|
|
<?php
|
|
$name = 'lien'; $label = 'Lien (site / ressource) :'; $value = $oldFn('lien');
|
|
$type = 'url'; $placeholder = 'https://...'; $hint = '';
|
|
$attrs = $withAutofocusFn('lien');
|
|
include APP_ROOT . '/templates/partials/form/text-field.php';
|
|
?>
|
|
</fieldset>
|
|
<?php
|