refresh form extension admin interface

Improve form editing, settings, submission lists, and navigation with responsive layouts and accessibility enhancements. Update the form wrapper block view and regenerate the extension stylesheet. Ignore .agents and skills-lock.json.
This commit is contained in:
2026-11-25 09:59:51 +01:00
parent ca7ee32091
commit 151ac9df4c
8 changed files with 231 additions and 120 deletions
@@ -21,7 +21,7 @@ $isEditing = isset($form['id']) && $form['id'] > 0;
<div class="mb-6">
<div class="flex items-center gap-3">
<a href="?tab=ext--form" class="btn btn-ghost btn-sm btn-circle">
<a href="?tab=ext--form" class="btn btn-ghost btn-sm btn-circle" aria-label="Back to forms" title="Back to forms">
<i class="ph-duotone ph-arrow-left text-xl"></i>
</a>
<div>
@@ -104,36 +104,36 @@ $isEditing = isset($form['id']) && $form['id'] > 0;
if(isset($form['id'])) echo '<input type="hidden" name="id" value="'.$form['id'].'">';
?>
<div class="card bg-base-100 shadow mb-6">
<div class="card mb-6 border border-base-300/60 bg-base-100 shadow-sm">
<div class="card-body">
<div class="flex items-center gap-2 mb-4">
<i class="ph-duotone ph-text-aa text-2xl text-base-content/60"></i>
<i class="ph-duotone ph-text-aa text-2xl text-primary" aria-hidden="true"></i>
<h3 class="card-title text-lg">Basics</h3>
</div>
<div class="form-control">
<label class="label">
<label class="label" for="form-name">
<span class="label-text font-medium">Form name</span>
</label>
<input type="text" name="name" value="<?= $form['name'] ?>" placeholder="e.g. Contact form" class="input input-bordered w-full" required />
<input id="form-name" type="text" name="name" value="<?= phpb_e($form['name']) ?>" placeholder="e.g. Contact form" class="input input-bordered w-full" required />
<span class="label-text-alt text-base-content/60">A unique name for your form.</span>
</div>
</div>
</div>
<div class="card bg-base-100 shadow mb-6">
<div class="card mb-6 border border-base-300/60 bg-base-100 shadow-sm">
<div class="card-body">
<div class="flex items-center gap-2 mb-4">
<i class="ph-duotone ph-list-dashes text-2xl text-base-content/60"></i>
<i class="ph-duotone ph-list-dashes text-2xl text-primary" aria-hidden="true"></i>
<h3 class="card-title text-lg">Form fields</h3>
</div>
<p class="text-sm text-base-content/60 mb-4">Define the fields users can fill out.</p>
<input type="hidden" name="fields" :value="JSON.stringify(fields)">
<div x-show="fields.length === 0" class="text-center py-8 border-2 border-dashed border-base-300 rounded-lg">
<div x-show="fields.length === 0" class="rounded-box border-2 border-dashed border-base-300 px-4 py-8 text-center">
<i class="ph-duotone ph-plus-circle text-4xl text-base-content/30"></i>
<p class="text-sm text-base-content/50 mt-2">No fields added yet</p>
<a href="javascript:void(0)" @click="addField()" class="btn btn-sm btn-primary mt-2">Add your first field</a>
<button type="button" @click="addField()" class="btn btn-sm btn-primary mt-2">Add your first field</button>
</div>
<div x-show="fields.length > 0" class="space-y-3">
@@ -151,33 +151,35 @@ $isEditing = isset($form['id']) && $form['id'] > 0;
@drop.prevent="moveField(dragIndex, index)"
@dragend="dragIndex = null"
>
<div class="flex items-center gap-2 mb-2">
<div class="mb-2 flex flex-col gap-2 sm:flex-row sm:items-center">
<!-- Drag handle -->
<button type="button" class="btn btn-ghost btn-xs btn-square cursor-grab active:cursor-grabbing text-base-content/40 hover:text-base-content" title="Drag to move">
<button type="button" class="btn btn-ghost btn-xs btn-square cursor-grab active:cursor-grabbing text-base-content/40 hover:text-base-content" title="Drag to move" aria-label="Drag to move field">
<i class="ph-duotone ph-dots-six-vertical text-lg"></i>
</button>
<span class="text-xs font-mono text-base-content/40 w-6">#[<span x-text="index + 1"></span>]</span>
<div class="flex-1">
<div class="w-full flex-1">
<input
type="text"
x-model="field.name"
placeholder="Field name"
placeholder="Field name"
:aria-label="'Field ' + (index + 1) + ' name'"
class="input input-bordered input-sm w-full"
:class="{'input-error': getValidationErrors(field, index).some(e => e.includes('Field name'))}"
/>
</div>
<div class="flex-1">
<div class="w-full flex-1">
<input
type="text"
x-model="field.label"
placeholder="Label"
placeholder="Label"
:aria-label="'Field ' + (index + 1) + ' label'"
class="input input-bordered input-sm w-full"
:class="{'input-error': getValidationErrors(field, index).some(e => e.includes('Label'))}"
/>
</div>
</div>
<!-- Validation errors -->
<div x-show="getValidationErrors(field, index).length > 0" x-transition class="mb-2 p-2 bg-error/10 border border-error/30 rounded text-error text-xs">
<div x-show="getValidationErrors(field, index).length > 0" x-transition class="mb-2 rounded border border-error/30 bg-error/10 p-2 text-xs text-error" role="alert" aria-live="polite">
<template x-for="(error, errIndex) in getValidationErrors(field, index)">
<div :key="errIndex" class="flex items-center gap-1">
<i class="ph-duotone ph-warning text-sm"></i>
@@ -185,8 +187,8 @@ $isEditing = isset($form['id']) && $form['id'] > 0;
</div>
</template>
</div>
<div class="flex items-center gap-2">
<select x-model="field.type" class="select select-bordered select-sm flex-1">
<div class="flex flex-wrap items-center gap-2">
<select x-model="field.type" class="select select-bordered select-sm min-w-40 flex-1" :aria-label="'Field ' + (index + 1) + ' type'">
<option value="text">Text</option>
<option value="email">Email</option>
<option value="textarea">Text area</option>
@@ -196,27 +198,27 @@ $isEditing = isset($form['id']) && $form['id'] > 0;
</select>
<label class="label cursor-pointer gap-2">
<span class="label-text text-sm">Required</span>
<input type="checkbox" x-model="field.required" class="checkbox checkbox-sm checkbox-primary" />
<input type="checkbox" x-model="field.required" class="checkbox checkbox-sm checkbox-primary" :aria-label="'Field ' + (index + 1) + ' is required'" />
</label>
<button @click="fields.splice(index, 1)" type="button" class="btn btn-ghost btn-sm btn-circle text-error" title="Remove">
<button @click="fields.splice(index, 1)" type="button" class="btn btn-ghost btn-sm btn-circle text-error" title="Remove" :aria-label="'Remove field ' + (index + 1)">
<i class="ph-duotone ph-trash"></i>
</button>
</div>
<div x-show="field.type === 'select' || field.type === 'checkbox' || field.type === 'radio'" x-transition class="mt-3 ml-2 pl-4 border-l-2 border-primary/30">
<div x-show="field.type === 'select' || field.type === 'checkbox' || field.type === 'radio'" x-transition class="mt-3 border-l-2 border-primary/30 pl-3 sm:ml-2 sm:pl-4">
<div class="flex items-center gap-2 mb-2">
<span class="text-xs font-medium text-base-content/60 uppercase tracking-wide" x-text="getOptionsLabel(field.type)"></span>
<a href="javascript:void(0)" @click="field.options.push({label: 'Option', value: 'option'})" class="btn btn-xs btn-ghost btn-primary">
<button type="button" @click="field.options.push({label: 'Option', value: 'option'})" class="btn btn-xs btn-ghost btn-primary">
<i class="ph-duotone ph-plus"></i>
Add
</a>
</button>
</div>
<div class="space-y-1">
<template x-for="(option, optIndex) in field.options">
<div class="flex items-center gap-2">
<div class="flex flex-col gap-2 sm:flex-row sm:items-center">
<span class="text-xs text-base-content/40 w-4">#[<span x-text="optIndex + 1"></span>]</span>
<input type="text" x-model="option.label" placeholder="Label" class="input input-bordered input-sm flex-1" />
<input type="text" x-model="option.value" placeholder="Value" class="input input-bordered input-sm flex-1" />
<button @click="field.options.splice(optIndex, 1)" type="button" class="btn btn-ghost btn-xs btn-circle text-error" title="Remove">
<input type="text" x-model="option.label" placeholder="Label" class="input input-bordered input-sm w-full flex-1" :aria-label="'Field ' + (index + 1) + ' option ' + (optIndex + 1) + ' label'" />
<input type="text" x-model="option.value" placeholder="Value" class="input input-bordered input-sm w-full flex-1" :aria-label="'Field ' + (index + 1) + ' option ' + (optIndex + 1) + ' value'" />
<button @click="field.options.splice(optIndex, 1)" type="button" class="btn btn-ghost btn-xs btn-circle text-error" title="Remove" :aria-label="'Remove option ' + (optIndex + 1) + ' from field ' + (index + 1)">
<i class="ph-duotone ph-x"></i>
</button>
</div>
@@ -228,28 +230,28 @@ $isEditing = isset($form['id']) && $form['id'] > 0;
</div>
<div class="mt-4">
<a href="javascript:void(0)" @click="addField()" class="btn btn-outline btn-sm btn-primary">
<button type="button" @click="addField()" class="btn btn-outline btn-sm btn-primary">
<i class="ph-duotone ph-plus"></i>
Add field
</a>
</button>
</div>
</div>
</div>
<div class="card bg-base-100 shadow mb-6">
<div class="card mb-6 border border-base-300/60 bg-base-100 shadow-sm">
<div class="card-body">
<div class="flex items-center gap-2 mb-4">
<i class="ph-duotone ph-gear text-2xl text-base-content/60"></i>
<i class="ph-duotone ph-gear text-2xl text-primary" aria-hidden="true"></i>
<h3 class="card-title text-lg">Actions</h3>
</div>
<p class="text-sm text-base-content/60 mb-4">What should happen when a form is submitted?</p>
<input type="hidden" name="finishers" :value="JSON.stringify(finishers)">
<div x-show="finishers.length === 0" class="text-center py-8 border-2 border-dashed border-base-300 rounded-lg">
<div x-show="finishers.length === 0" class="rounded-box border-2 border-dashed border-base-300 px-4 py-8 text-center">
<i class="ph-duotone ph-plus-circle text-4xl text-base-content/30"></i>
<p class="text-sm text-base-content/50 mt-2">No actions added yet</p>
<a href="javascript:void(0)" @click="addFinisher()" class="btn btn-sm btn-primary mt-2">Add your first action</a>
<button type="button" @click="addFinisher()" class="btn btn-sm btn-primary mt-2">Add your first action</button>
</div>
<div x-show="finishers.length > 0" class="space-y-2">
@@ -257,21 +259,21 @@ $isEditing = isset($form['id']) && $form['id'] > 0;
<div class="p-3 border border-base-300 rounded-lg bg-base-200/50 space-y-3">
<div class="flex items-center gap-3">
<span class="text-xs font-mono text-base-content/40">#[<span x-text="index + 1"></span>]</span>
<select :value="finisher.type" @change="setFinisherType(finisher, $event.target.value)" class="select select-bordered select-sm flex-1">
<select :value="finisher.type" @change="setFinisherType(finisher, $event.target.value)" class="select select-bordered select-sm min-w-40 flex-1" :aria-label="'Action ' + (index + 1) + ' type'">
<template x-for="(definition, type) in finisherDefinitions" :key="type">
<option :value="type" x-text="definition.label"></option>
</template>
</select>
<button @click="finishers.splice(index, 1)" type="button" class="btn btn-ghost btn-sm btn-circle text-error" title="Remove">
<button @click="finishers.splice(index, 1)" type="button" class="btn btn-ghost btn-sm btn-circle text-error" title="Remove" :aria-label="'Remove action ' + (index + 1)">
<i class="ph-duotone ph-trash"></i>
</button>
</div>
<div x-show="getFinisherSettings(finisher.type).length > 0" class="space-y-3 pl-8">
<template x-for="setting in getFinisherSettings(finisher.type)" :key="setting.name">
<div class="form-control">
<label class="label"><span class="label-text" x-text="setting.label"></span></label>
<label class="label" :for="'finisher-' + index + '-' + setting.name"><span class="label-text" x-text="setting.label"></span></label>
<template x-if="setting.type === 'emailField'">
<select x-model="finisher.options[setting.name]" :required="setting.required || false" class="select select-bordered select-sm w-full">
<select :id="'finisher-' + index + '-' + setting.name" x-model="finisher.options[setting.name]" :required="setting.required || false" class="select select-bordered select-sm w-full">
<option value="">Select an email field</option>
<template x-for="field in fields.filter(field => field.type === 'email')" :key="field.name">
<option :value="field.name" x-text="field.label + ' (' + field.name + ')' "></option>
@@ -279,17 +281,17 @@ $isEditing = isset($form['id']) && $form['id'] > 0;
</select>
</template>
<template x-if="setting.type === 'select'">
<select x-model="finisher.options[setting.name]" :required="setting.required || false" class="select select-bordered select-sm w-full">
<select :id="'finisher-' + index + '-' + setting.name" x-model="finisher.options[setting.name]" :required="setting.required || false" class="select select-bordered select-sm w-full">
<template x-for="option in setting.options || []" :key="option.value">
<option :value="option.value" x-text="option.label"></option>
</template>
</select>
</template>
<template x-if="setting.type === 'textarea'">
<textarea x-model="finisher.options[setting.name]" :required="setting.required || false" :placeholder="setting.placeholder || ''" class="textarea textarea-bordered w-full" rows="4"></textarea>
<textarea :id="'finisher-' + index + '-' + setting.name" x-model="finisher.options[setting.name]" :required="setting.required || false" :placeholder="setting.placeholder || ''" class="textarea textarea-bordered w-full" rows="4"></textarea>
</template>
<template x-if="!['emailField', 'select', 'textarea'].includes(setting.type)">
<input x-model="finisher.options[setting.name]" :type="setting.type" :required="setting.required || false" :min="setting.min" :max="setting.max" :placeholder="setting.placeholder || ''" class="input input-bordered input-sm w-full" />
<input :id="'finisher-' + index + '-' + setting.name" x-model="finisher.options[setting.name]" :type="setting.type" :required="setting.required || false" :min="setting.min" :max="setting.max" :placeholder="setting.placeholder || ''" class="input input-bordered input-sm w-full" />
</template>
<span x-show="setting.help" class="label-text-alt text-base-content/60 mt-1" x-text="setting.help"></span>
</div>
@@ -301,19 +303,19 @@ $isEditing = isset($form['id']) && $form['id'] > 0;
</div>
<div class="mt-4">
<a href="javascript:void(0)" @click="addFinisher()" class="btn btn-outline btn-sm btn-primary">
<button type="button" @click="addFinisher()" class="btn btn-outline btn-sm btn-primary">
<i class="ph-duotone ph-plus"></i>
Add action
</a>
</button>
</div>
</div>
</div>
<div class="flex justify-end gap-2">
<a href="?tab=ext--form" class="btn btn-ghost btn-sm">
<div class="flex flex-col-reverse gap-2 sm:flex-row sm:justify-end">
<a href="?tab=ext--form" class="btn btn-ghost btn-sm sm:min-w-28">
Cancel
</a>
<button type="submit" class="btn btn-primary btn-sm">
<button type="submit" class="btn btn-primary btn-sm sm:min-w-28">
<i class="ph-duotone ph-floppy-disk"></i>
Save
</button>