mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
Add website-type TFE support: URLs stored as thesis_files rows, HTMX-toggle on Site web format
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user