Files
xamxam/app/templates/partials/form/file-field.php
Pontoporeia df70fba5d4 feat: convert all file inputs to FilePond for standardized uploading
- Add csv_import queue type (storeAsFile, no async upload) for CSV import dialog
- Convert file-field.php partial to FilePond with field-name→queue-type mapping
- Conditionally skip server config for storeAsFile queues in buildFilePondOptions
- Skip FilePond init for inputs inside closed <dialog> elements
- Trigger FilePond init when import dialog opens
- Load FilePond CSS/JS assets on admin index page
2026-06-09 13:12:22 +02:00

48 lines
2.0 KiB
PHP

<?php
/**
* File input partial — FilePond-powered.
*
* Variables consumed:
* string $name — input name attribute (used for id too unless $id set)
* string $label — visible label text
* string $accept — MIME types / extensions (informational; FilePond validates via queue config)
* string|null $hint — optional hint shown in <small> below the input
* bool $required — whether the field is required; default false
* bool $multiple — whether to allow multiple file selection; default false
* string|null $id — override the id attribute (defaults to $name)
* string|null $fieldName — mapped to FilePond queue-type: 'couverture'→cover, 'note_intention'→note_intention, 'annexes'→annexe
*/
$accept = $accept ?? '';
$hint = $hint ?? null;
$hintRaw = $hintRaw ?? false; // when true, $hint is emitted as raw HTML
$required = $required ?? false;
$multiple = $multiple ?? false;
$id = $id ?? $name;
$fieldName = $fieldName ?? $name;
// Map legacy field names to FilePond queue types
$queueTypeMap = [
'couverture' => 'cover',
'note_intention' => 'note_intention',
'annexes' => 'annexe',
];
$queueType = $queueTypeMap[$fieldName] ?? null;
?>
<div class="admin-form-group">
<label for="<?= htmlspecialchars($id) ?>"><?= htmlspecialchars($label) ?><?= $required ? ' <span class="asterisk">*</span>' : '' ?></label>
<div class="admin-file-input">
<input type="file"
id="<?= htmlspecialchars($id) ?>"
name="queue_file[<?= htmlspecialchars($queueType ?? $fieldName) ?>][]"
class="tfe-file-picker"
data-queue-type="<?= htmlspecialchars($queueType ?? 'annexe') ?>"
<?= $required ? 'required' : '' ?>>
<?php if ($hint): ?>
<small><?= $hintRaw ? $hint : htmlspecialchars($hint) ?></small>
<?php endif; ?>
</div>
</div>
<?php
unset($accept, $hint, $hintRaw, $required, $multiple, $id, $fieldName, $queueType, $queueTypeMap);