Add website-type TFE support: URLs stored as thesis_files rows, HTMX-toggle on Site web format

This commit is contained in:
Pontoporeia
2026-05-07 21:24:46 +02:00
parent 9dc7ea98f2
commit ac0008df6c
10 changed files with 399 additions and 39 deletions

View File

@@ -13,21 +13,33 @@
* array $options — each element must have 'id' and 'name' keys
* array $checked — array of 'id' values that are currently checked
* bool $required — whether at least one checkbox must be checked; default false
* string $hxPost — optional hx-post URL for HTMX live update
* string $hxTarget — optional hx-target CSS selector for HTMX swap
*/
$checked = $checked ?? [];
$required = $required ?? false;
$checked = $checked ?? [];
$required = $required ?? false;
$hxPost = $hxPost ?? '';
$hxTarget = $hxTarget ?? '';
?>
<div>
<span class="admin-row-label"><?= htmlspecialchars($label) ?><?= $required ? ' <span class="asterisk">*</span>' : '' ?></span>
<fieldset class="admin-checkbox-group"<?= $required ? ' required aria-required="true"' : '' ?>>
<fieldset class="admin-checkbox-group"
<?= $required ? ' required aria-required="true"' : '' ?>
<?php if ($hxPost !== ''): ?>
hx-post="<?= htmlspecialchars($hxPost) ?>"
hx-target="<?= htmlspecialchars($hxTarget) ?>"
hx-trigger="change"
hx-include="this, #website-url-fieldset"
hx-swap="outerHTML"
<?php endif; ?>>
<legend class="sr-only"><?= htmlspecialchars($label) ?></legend>
<ul>
<?php foreach ($options as $opt): ?>
<li>
<label class="admin-checkbox-label">
<input type="checkbox"
name="<?= htmlspecialchars($name) ?>[]"
name="<?= htmlspecialchars($name) ?>[]"
value="<?= htmlspecialchars((string)$opt['id']) ?>"
<?= in_array((string)$opt['id'], array_map('strval', $checked)) ? 'checked' : '' ?>>
<?= htmlspecialchars($opt['name']) ?>
@@ -38,4 +50,4 @@ $required = $required ?? false;
</fieldset>
</div>
<?php
unset($checked);
unset($checked, $hxPost, $hxTarget);