Remove required from all admin add/edit form inputs

- Skip required-field validation for orientation/ap/finality/licence/jury in admin add+edit
This commit is contained in:
Pontoporeia
2026-05-08 12:40:06 +02:00
parent 5735ccbc38
commit 95fcbc919a
12 changed files with 216 additions and 98 deletions

View File

@@ -181,62 +181,8 @@ class ThesisEditController
$errors[] = "L'année est invalide.";
}
$orientationId = intval($post['orientation'] ?? 0);
if ($orientationId <= 0) {
$errors[] = "L'orientation est requise.";
}
$apProgramId = intval($post['ap'] ?? 0);
if ($apProgramId <= 0) {
$errors[] = "L'atelier pluridisciplinaire est requis.";
}
$finalityId = intval($post['finality'] ?? 0);
if ($finalityId <= 0) {
$errors[] = 'La finalité est requise.';
}
// Languages
$langIds = isset($post['languages']) && is_array($post['languages']) ? $post['languages'] : [];
if (empty($langIds)) {
$errors[] = 'Au moins une langue est requise.';
}
// Formats
$fmtIds = isset($post['formats']) && is_array($post['formats']) ? $post['formats'] : [];
if (empty($fmtIds)) {
$errors[] = 'Au moins un format est requis.';
}
// Licence
$licenseId = filter_var($post['license_id'] ?? '', FILTER_VALIDATE_INT) ?: null;
$licenseCustom = trim($post['license_custom'] ?? '');
if (!$licenseId && $licenseCustom === '') {
$errors[] = 'Une licence est requise.';
}
// Jury
$hasPromoteur = !empty(trim($post['jury_promoteur'] ?? ''));
$hasLecteurInt = false;
$hasLecteurExt = false;
foreach ($post['jury_lecteur_interne'] ?? [] as $n) {
if (trim((string)$n) !== '') {
$hasLecteurInt = true;
break;
}
}
foreach ($post['jury_lecteur_externe'] ?? [] as $n) {
if (trim((string)$n) !== '') {
$hasLecteurExt = true;
break;
}
}
if (!$hasPromoteur) {
$errors[] = 'Un·e promoteur·ice interne est requis.';
}
if (!$hasLecteurInt) {
$errors[] = 'Au moins un·e lecteur·ice interne est requis.';
}
if (!$hasLecteurExt) {
$errors[] = 'Au moins un·e lecteur·ice externe est requis.';
}
if (!empty($errors)) {
throw new RuntimeException(implode(' ', $errors));