mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-08-10 15:21:22 +02:00
Issue 1 — hidden seeds overriding user input: Removed all hidden seed inputs (cc2r, want_license, license_id, license_custom). The .licence-license-choice div is now rendered directly from $formData on page load instead of via HTMX load trigger. This eliminates stale-seed interference on both HTMX radio changes and full form submits. Issue 2 — Interne want_license uncheck clearing CC2r: When want_license is unchecked, CC2r and licence selections are cleared (section hidden). Added hidden want_license=0 so the fragment handler can distinguish "arriving from another access type" (no want_license in POST → preserve values) from "explicit Interne toggle" (want_license present → clear CC2r if off). CC2r is independently toggleable within the visible section. Licence dropdown placeholder changed to 'Aucune licence' for an explicit no-licence choice.
28 lines
1.1 KiB
PHP
28 lines
1.1 KiB
PHP
<?php
|
|
/**
|
|
* Admin fragment: licence section (HTMX partial).
|
|
*/
|
|
require_once __DIR__ . '/../../../bootstrap.php';
|
|
require_once __DIR__ . '/../../../src/AdminAuth.php';
|
|
AdminAuth::requireLogin();
|
|
|
|
require_once APP_ROOT . '/src/Database.php';
|
|
require_once APP_ROOT . '/src/FragmentRenderer.php';
|
|
|
|
$licenseTypes = Database::getInstance()->getAllLicenseTypes();
|
|
|
|
$fromInterne = array_key_exists('want_license', $_POST);
|
|
$wantLicense = $fromInterne ? !empty($_POST['want_license']) : (!empty($_POST['cc2r']) || !empty($_POST['license_id']) || !empty($_POST['license_custom']));
|
|
$cc2r = ($fromInterne && !$wantLicense) ? false : !empty($_POST['cc2r']);
|
|
|
|
FragmentRenderer::render('form/_licence', [
|
|
'adminMode' => true,
|
|
'accessTypeId' => $_POST['access_type_id'] ?? '',
|
|
'licenseId' => $_POST['license_id'] ?? '',
|
|
'licenseCustom' => $_POST['license_custom'] ?? '',
|
|
'cc2r' => $cc2r,
|
|
'wantLicense' => $wantLicense,
|
|
'hxPost' => '/admin/fragments/licence.php',
|
|
'licenseTypes' => $licenseTypes,
|
|
]);
|