mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
fix: req annexes, add HTMX inline file validation (MIME/size)
- Annexes file input now required when 'has_annexes' checkbox is checked
- PHP-side validation: if has_annexes but no files, throw error
- HTMX inline file validation: POSTs to validate-file-fragment on file change
- Validates MIME type against per-field whitelists (couverture, note_intention,
tfe, annexes)
- Validates file size with PDF-specific 100MB limit
- Supports both single-file and multi-file inputs
- Returns green ✓ or red ✕ inline validation messages
- Shared validation logic in src/Controllers/validate-file-fragment-shared.php
- Admin wrapper: admin/validate-file-fragment.php (with AdminAuth guard)
- Partage route: /partage/validate-file-fragment (dispatched via index.php)
- CSS: .file-validation-msg, .fv-ok (green), .fv-error (red)
- file-field.php: accepts $fieldName for per-input validation type,
auto-detects admin/partage validate URL
This commit is contained in:
@@ -197,7 +197,7 @@ $hasAnnexesChecked = !empty($_POST['has_annexes']);
|
||||
$label = 'Annexes :';
|
||||
$accept = '.pdf,.zip,.tar,.gz';
|
||||
$hint = 'PDF ou archives ZIP/TAR. Max 500 MB.';
|
||||
$required = false;
|
||||
$required = !$adminMode;
|
||||
$multiple = true;
|
||||
include APP_ROOT . '/templates/partials/form/file-field.php';
|
||||
?>
|
||||
|
||||
@@ -36,6 +36,13 @@ if ($slug === 'format-website-fragment' && $_SERVER['REQUEST_METHOD'] === 'POST'
|
||||
exit;
|
||||
}
|
||||
|
||||
// Special route: /partage/validate-file-fragment (HTMX fragment — file MIME/size validation)
|
||||
if ($slug === 'validate-file-fragment' && $_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
App::boot();
|
||||
require_once __DIR__ . '/../../src/Controllers/validate-file-fragment-shared.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
// Special route: /partage/fichiers-fragment (HTMX fragment — format-aware fichiers block)
|
||||
if ($slug === 'fichiers-fragment' && $_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
App::boot();
|
||||
|
||||
Reference in New Issue
Block a user