mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-08-10 23:31:21 +02:00
Fix CC2r: uncheck not persisting + want_license hiding cc2r when active
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.
This commit is contained in:
@@ -119,20 +119,18 @@ $adminMode = $adminMode ?? false;
|
||||
<p class="licence-note"><em>L'auteur·ice peut, à tout moment, décider de restreindre son propre choix. Iel ne peut par contre pas l'ouvrir.</em></p>
|
||||
</div>
|
||||
|
||||
<!-- Seed saved licence values for the initial htmx load.
|
||||
These are overridden by visible inputs inside .licence-license-choice
|
||||
once htmx renders them - later DOM order wins in POST. -->
|
||||
<input type="hidden" name="license_id" value="<?= htmlspecialchars((string)($formData['license_id'] ?? '')) ?>">
|
||||
<input type="hidden" name="license_custom" value="<?= htmlspecialchars($formData['license_custom'] ?? '') ?>">
|
||||
<input type="hidden" name="cc2r" value="<?= !empty($formData['cc2r']) ? '1' : '' ?>">
|
||||
<?php $wantLicense = !empty($formData['license_id']) || !empty($formData['license_custom']); ?>
|
||||
<input type="hidden" name="want_license" value="<?= $wantLicense ? '1' : '' ?>">
|
||||
|
||||
<!-- Licence - swapped via htmx when radio changes -->
|
||||
<div class="licence-license-choice"
|
||||
hx-post="<?= $adminMode ? '/admin/fragments/licence.php' : '/partage/fragments/licence.php' ?>"
|
||||
hx-trigger="load"
|
||||
hx-include="closest fieldset"
|
||||
hx-swap="outerHTML">
|
||||
</div>
|
||||
<!-- Licence - rendered from stored data on page load; swapped via htmx when radio changes -->
|
||||
<?php
|
||||
$initialAccess = array_key_exists('access_type_id', $formData) ? $formData['access_type_id'] : $defaultAccessTypeId;
|
||||
if ($initialAccess === '' || $initialAccess === null) {
|
||||
$initialAccess = (string)$defaultAccessTypeId;
|
||||
}
|
||||
$cc2r = !empty($formData['cc2r']);
|
||||
$wantLicense = $cc2r || !empty($formData['license_id']) || !empty($formData['license_custom']);
|
||||
$licenseId = $formData['license_id'] ?? '';
|
||||
$licenseCustom = $formData['license_custom'] ?? '';
|
||||
$accessTypeId = (string)$initialAccess;
|
||||
$hxPost = $adminMode ? '/admin/fragments/licence.php' : '/partage/fragments/licence.php';
|
||||
include APP_ROOT . '/templates/partials/form/_licence.php';
|
||||
?>
|
||||
</fieldset>
|
||||
|
||||
Reference in New Issue
Block a user