Phase 3: Attendee Type Field Builder Improvements
Historical design/implementation plan. It is retained as background, not a statement that every proposed feature is available. Use the current component/project guides and the deployed editor before following its recipes.
Overview
This document details enhancements to the attendee type field builder, including improved field management UI, suggested fields system, AI translation fields, default field markers, and password authentication configuration.
Feature Summary
- Quick-Add Card UI: Fast field creation with section selection
- Suggested Fields System: Global templates with project plan overrides
- Default Fields: Mark fields as included for all attendee types
- Quick Add Field Markers: Mark fields to show in attendee create form
- AI Translation Fields: Auto-translate values using Google/Vertex AI
- Password Authentication Config: Separate password settings per type
- Enhanced Validation UI: Better validation rule configuration
- Slug Auto-Generation: Auto-generate with optional override
1. Quick-Add Card UI for Field Creation
Design Pattern
The field creation interface should follow the FormBuilder quick-add card pattern:
┌─────────────────────────────────────────────────────────────────┐
│ Attendee Fields │
├─────────────────────────────────────────────────────────────────┤
│ │
│ ┌─ Section: Contact Information ─────────────────────────────┐ │
│ │ [+ Add Field to Section] │ │
│ │ │ │
│ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ │
│ │ │ Email │ │ Phone │ │ Alt Email │ │ │
│ │ │ ≡ ✎ ⋮ │ │ ≡ ✎ ⋮ │ │ ≡ ✎ ⋮ │ │ │
│ │ └──────────────┘ └──────────────┘ └──────────────┘ │ │
│ └────────────────────────────────────────────────────────────┘ │
│ │
│ ┌─ Section: Personal Information ────────────────────────────┐ │
│ │ [+ Add Field to Section] │ │
│ │ │ │
│ │ ┌──────────────┐ ┌──────────────┐ │ │
│ │ │ First Name │ │ Last Name │ │ │
│ │ │ ≡ ✎ ⋮ │ │ ≡ ✎ ⋮ │ │ │
│ │ └──────────────┘ └──────────────┘ │ │
│ └───────────────────────────────────────────── ───────────────┘ │
│ │
│ [+ Add Section] [+ Add Field] │
│ │
└─────────────────────────────────────────────────────────────────┘
Quick-Add Field Card Component
<!-- resources/js/Components/Attendee/FieldQuickAddCard.vue -->
<script setup>
import { ref, computed } from 'vue'
import { useForm } from '@inertiajs/vue3'
import ModCard from '@/Components/Mod/v2/Cards/ModCard.vue'
import ModButton from '@/Components/Mod/v2/Elements/ModButton.vue'
import ModSelect from '@/Components/Mod/v2/Elements/Selects/ModSelect.vue'
import ModInput from '@/Components/Mod/v2/Elements/Inputs/ModInput.vue'
import ModSwitch from '@/Components/Mod/v2/Elements/Boolean/ModSwitch.vue'
import { attendeeFieldTypes } from '@/Data/attendeeFieldTypes'
const props = defineProps({
sections: { type: Array, default: () => [] },
preselectedSection: { type: [Number, String], default: null },
projectSlug: { type: String, required: true },
})
const emit = defineEmits(['field-created', 'cancel'])
const form = useForm({
name: '',
slug: '',
field_type: 'text',
section_id: props.preselectedSection,
is_required: false,
is_default_for_all_types: false,
include_in_quick_add: false,
validation_rules: null,
})
const slugManuallyEdited = ref(false)
const showAdvanced = ref(false)
// Auto-generate slug from name
const generateSlug = (name) => {
return name
.toLowerCase()
.replace(/[^a-z0-9]+/g, '_')
.replace(/^_|_$/g, '')
}
const onNameChange = (value) => {
form.name = value
if (!slugManuallyEdited.value) {
form.slug = generateSlug(value)
}
}
const onSlugChange = (value) => {
form.slug = value
slugManuallyEdited.value = true
}
const fieldTypeOptions = computed(() =>
Object.entries(attendeeFieldTypes).map(([value, config]) => ({
value,
label: config.label,
icon: config.icon,
}))
)
const sectionOptions = computed(() =>
props.sections.map(s => ({
value: s.id,
label: s.title,
}))
)
const submit = () => {
form.post(route('dashboard.project.attendee-fields.store', {
project: props.projectSlug,
}), {
preserveScroll: true,
onSuccess: () => {
emit('field-created', form.data())
form.reset()
slugManuallyEdited.value = false
},
})
}
</script>
<template>
<ModCard
title="Quick Add Field"
icon="plus-circle"
class="field-quick-add-card"
collapsible
:collapsed="false"
>
<form @submit.prevent="submit" class="row g-3">
<!-- Field Name -->
<div class="col-md-6">
<ModInput
v-model="form.name"
label="Field Name"
placeholder="e.g., First Name"
required
@update:modelValue="onNameChange"
:error="form.errors.name"
/>
</div>
<!-- Field Slug -->
<div class="col-md-6">
<ModInput
v-model="form.slug"
label="Field Slug"
placeholder="e.g., first_name"
required
@update:modelValue="onSlugChange"
:error="form.errors.slug"
>
<template #hint>
<span v-if="!slugManuallyEdited" class="text-muted">
Auto-generated from name
</span>
</template>
</ModInput>
</div>
<!-- Field Type -->
<div class="col-md-6">
<ModSelect
v-model="form.field_type"
label="Field Type"
:options="fieldTypeOptions"
required
:error="form.errors.field_type"
/>
</div>
<!-- Section -->
<div class="col-md-6">
<ModSelect
v-model="form.section_id"
label="Section"
:options="sectionOptions"
placeholder="Select section..."
:error="form.errors.section_id"
/>
</div>
<!-- Quick Options -->
<div class="col-12">
<div class="d-flex flex-wrap gap-4">
<ModSwitch
v-model="form.is_required"
label="Required"
/>
<ModSwitch
v-model="form.is_default_for_all_types"
label="Default for All Types"
/>
<ModSwitch
v-model="form.include_in_quick_add"
label="Include in Quick Add Form"
/>
</div>
</div>
<!-- Advanced Options Toggle -->
<div class="col-12">
<a
href="#"
class="text-muted small"
@click.prevent="showAdvanced = !showAdvanced"
>
{{ showAdvanced ? 'Hide' : 'Show' }} Advanced Options
<ModIcon :icon="showAdvanced ? 'chevron-up' : 'chevron-down'" />
</a>
</div>
<!-- Advanced Options -->
<template v-if="showAdvanced">
<div class="col-12">
<ValidationRulesBuilder
v-model="form.validation_rules"
:field-type="form.field_type"
/>
</div>
</template>
<!-- Actions -->
<div class="col-12 d-flex justify-content-end gap-2">
<ModButton
type="button"
color="secondary"
outline
@click="emit('cancel')"
>
Cancel
</ModButton>
<ModButton
type="submit"
color="primary"
:disabled="form.processing"
>
<span v-if="form.processing" class="spinner-border spinner-border-sm me-1" />
Create Field
</ModButton>
</div>
</form>
</ModCard>
</template>
Section-Aware Add Field Buttons
Each section header includes its own "Add Field" button that pre-populates the section:
<!-- resources/js/Components/Attendee/FieldSectionCard.vue -->
<script setup>
import { ref } from 'vue'
import ModCard from '@/Components/Mod/v2/Cards/ModCard.vue'
import ModButton from '@/Components/Mod/v2/Elements/ModButton.vue'
import FieldQuickAddCard from './FieldQuickAddCard.vue'
import FieldItemCard from './FieldItemCard.vue'
import draggable from 'vuedraggable'
const props = defineProps({
section: { type: Object, required: true },
fields: { type: Array, default: () => [] },
allSections: { type: Array, default: () => [] },
projectSlug: { type: String, required: true },
})
const emit = defineEmits(['field-moved', 'field-updated', 'field-deleted', 'reorder'])
const showQuickAdd = ref(false)
const showMoveDropdown = ref(null)
const onDragEnd = (event) => {
const fieldId = props.fields[event.newIndex].id
emit('reorder', {
sectionId: props.section.id,
fieldId,
newIndex: event.newIndex,
})
}
const moveFieldToSection = (field, targetSectionId) => {
emit('field-moved', {
fieldId: field.id,
fromSectionId: props.section.id,
toSectionId: targetSectionId,
})
showMoveDropdown.value = null
}
</script>
<template>
<ModCard
:title="section.title"
icon="folder"
class="field-section-card mb-3"
collapsible
>
<template #header-actions>
<ModButton
size="sm"
color="primary"
outline
@click="showQuickAdd = true"
>
<ModIcon icon="plus" class="me-1" />
Add Field
</ModButton>
</template>
<!-- Quick Add Form (Inline) -->
<FieldQuickAddCard
v-if="showQuickAdd"
:sections="allSections"
:preselected-section="section.id"
:project-slug="projectSlug"
@field-created="showQuickAdd = false"
@cancel="showQuickAdd = false"
class="mb-3"
/>
<!-- Draggable Fields List -->
<draggable
:list="fields"
item-key="id"
handle=".drag-handle"
@end="onDragEnd"
class="row g-2"
>
<template #item="{ element: field }">
<div class="col-md-6 col-lg-4">
<FieldItemCard
:field="field"
@edit="emit('field-updated', field)"
@delete="emit('field-deleted', field)"
>
<template #actions>
<!-- Move to Section Dropdown -->
<MDBDropdown v-model="showMoveDropdown">
<MDBDropdownToggle
tag="button"
class="btn btn-sm btn-link p-1"
title="Move to Section"
>
<ModIcon icon="arrow-right-arrow-left" />
</MDBDropdownToggle>
<MDBDropdownMenu>
<MDBDropdownItem
v-for="s in allSections.filter(s => s.id !== section.id)"
:key="s.id"
@click="moveFieldToSection(field, s.id)"
>
{{ s.title }}
</MDBDropdownItem>
</MDBDropdownMenu>
</MDBDropdown>
</template>
</FieldItemCard>
</div>
</template>
</draggable>
<p v-if="fields.length === 0 && !showQuickAdd" class="text-muted text-center py-4">
No fields in this section.
<a href="#" @click.prevent="showQuickAdd = true">Add one</a>
</p>
</ModCard>
</template>
2. Suggested Fields System
Backend Service
<?php
namespace App\Services;
use App\Models\SuggestedFieldTemplate;
use App\Models\AttendeeType;
use App\Models\AttendeeField;
use App\Models\Project;
use Illuminate\Support\Collection;
class SuggestedFieldService
{
public function __construct(
protected AttendeeFieldService $fieldService,
) {}
/**
* Get suggested fields for a new attendee type
*/
public function getSuggestionsForType(
string $attendeeTypeName,
Project $project
): Collection {
$template = SuggestedFieldTemplate::findForAttendeeType(
$attendeeTypeName,
$project->project_plan_id
);
if (!$template) {
return collect();
}
return $template->items->map(fn ($item) => [
'name' => $item->name,
'slug' => $item->slug,
'field_type' => $item->field_type,
'is_required' => $item->is_required,
'is_default_for_all_types' => $item->is_default_for_all_types,
'include_in_quick_add' => $item->include_in_quick_add,
'validation_rules' => $item->validation_rules,
'options' => $item->options,
'section_name' => $item->section_name,
'template_id' => $template->id,
'template_name' => $template->name,
]);
}
/**
* Apply suggested fields to a new attendee type
*/
public function applySuggestions(
AttendeeType $attendeeType,
array $selectedSuggestions
): array {
$createdFields = [];
$sectionCache = [];
foreach ($selectedSuggestions as $suggestion) {
// Get or create section
$sectionId = null;
if ($suggestion['section_name']) {
if (!isset($sectionCache[$suggestion['section_name']])) {
$section = $this->getOrCreateSection(
$attendeeType->project,
$suggestion['section_name']
);
$sectionCache[$suggestion['section_name']] = $section->id;
}
$sectionId = $sectionCache[$suggestion['section_name']];
}
// Check if field already exists
$existingField = AttendeeField::where('project_id', $attendeeType->project_id)
->where('slug', $suggestion['slug'])
->first();
if ($existingField) {
// Just attach to type if not already
$this->attachFieldToType($attendeeType, $existingField, $sectionId);
$createdFields[] = $existingField;
} else {
// Create new field
$field = $this->fieldService->create([
'project_id' => $attendeeType->project_id,
'name' => $suggestion['name'],
'slug' => $suggestion['slug'],
'field_type' => $suggestion['field_type'],
'is_default_for_all_types' => $suggestion['is_default_for_all_types'],
'include_in_quick_add' => $suggestion['include_in_quick_add'],
'validation_rules' => $suggestion['validation_rules'],
]);
// Create enum options if needed
if (!empty($suggestion['options'])) {
foreach ($suggestion['options'] as $option) {
$field->fieldEnums()->create($option);
}
}
$this->attachFieldToType($attendeeType, $field, $sectionId);
$createdFields[] = $field;
}
}
return $createdFields;
}
protected function attachFieldToType(
AttendeeType $attendeeType,
AttendeeField $field,
?int $sectionId
): void {
// Implementation to attach field to type's section
}
protected function getOrCreateSection(Project $project, string $name)
{
return FieldSection::firstOrCreate(
['project_id' => $project->id, 'title' => $name],
['title' => $name]
);
}
}
Frontend Suggested Fields Component
<!-- resources/js/Components/Attendee/SuggestedFieldsSelector.vue -->
<script setup>
import { ref, computed, watch } from 'vue'
import ModCard from '@/Components/Mod/v2/Cards/ModCard.vue'
import ModButton from '@/Components/Mod/v2/Elements/ModButton.vue'
import ModCheckbox from '@/Components/Mod/v2/Elements/Boolean/ModCheckbox.vue'
import ModIcon from '@/Components/Mod/ModIcon.vue'
const props = defineProps({
attendeeTypeName: { type: String, default: '' },
projectSlug: { type: String, required: true },
})
const emit = defineEmits(['apply', 'skip'])
const loading = ref(false)
const suggestions = ref([])
const selectedSlugs = ref([])
const templateInfo = ref(null)
// Fetch suggestions when type name changes
watch(() => props.attendeeTypeName, async (name) => {
if (name.length < 2) {
suggestions.value = []
return
}
loading.value = true
try {
const response = await axios.get(route('api.suggested-fields.lookup', {
project: props.projectSlug,
type_name: name,
}))
suggestions.value = response.data.suggestions
templateInfo.value = response.data.template
// Pre-select all by default
selectedSlugs.value = suggestions.value.map(s => s.slug)
} catch (error) {
console.error('Failed to fetch suggestions:', error)
} finally {
loading.value = false
}
}, { immediate: true })
const groupedSuggestions = computed(() => {
const groups = {}
for (const suggestion of suggestions.value) {
const section = suggestion.section_name || 'General'
if (!groups[section]) {
groups[section] = []
}
groups[section].push(suggestion)
}
return groups
})
const toggleAll = (checked) => {
selectedSlugs.value = checked ? suggestions.value.map(s => s.slug) : []
}
const isSelected = (slug) => selectedSlugs.value.includes(slug)
const toggleSelection = (slug) => {
const index = selectedSlugs.value.indexOf(slug)
if (index > -1) {
selectedSlugs.value.splice(index, 1)
} else {
selectedSlugs.value.push(slug)
}
}
const apply = () => {
const selected = suggestions.value.filter(s => selectedSlugs.value.includes(s.slug))
emit('apply', selected)
}
</script>
<template>
<ModCard
v-if="suggestions.length > 0"
title="Suggested Fields"
icon="lightbulb"
class="suggested-fields-card"
>
<template #subtitle>
<span v-if="templateInfo" class="text-muted small">
Based on "{{ templateInfo.name }}" template
</span>
</template>
<div v-if="loading" class="text-center py-4">
<span class="spinner-border spinner-border-sm" />
Loading suggestions...
</div>
<template v-else>
<!-- Select All -->
<div class="d-flex justify-content-between align-items-center mb-3 pb-2 border-bottom">
<ModCheckbox
:model-value="selectedSlugs.length === suggestions.length"
:indeterminate="selectedSlugs.length > 0 && selectedSlugs.length < suggestions.length"
label="Select All"
@update:modelValue="toggleAll"
/>
<span class="text-muted small">
{{ selectedSlugs.length }} of {{ suggestions.length }} selected
</span>
</div>
<!-- Grouped Suggestions -->
<div
v-for="(fields, sectionName) in groupedSuggestions"
:key="sectionName"
class="mb-3"
>
<h6 class="text-muted mb-2">{{ sectionName }}</h6>
<div class="row g-2">
<div
v-for="field in fields"
:key="field.slug"
class="col-md-6"
>
<div
class="suggested-field-item p-2 border rounded"
:class="{ 'border-primary bg-light': isSelected(field.slug) }"
@click="toggleSelection(field.slug)"
role="button"
>
<div class="d-flex align-items-center">
<ModCheckbox
:model-value="isSelected(field.slug)"
class="me-2"
@click.stop
@update:modelValue="toggleSelection(field.slug)"
/>
<div class="flex-grow-1">
<div class="fw-medium">{{ field.name }}</div>
<div class="small text-muted">
{{ field.field_type }}
<span v-if="field.is_required" class="text-danger">*</span>
<span v-if="field.is_default_for_all_types" class="badge bg-info ms-1">
Default
</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Actions -->
<div class="d-flex justify-content-end gap-2 mt-3 pt-3 border-top">
<ModButton
color="secondary"
outline
@click="emit('skip')"
>
Skip Suggestions
</ModButton>
<ModButton
color="primary"
:disabled="selectedSlugs.length === 0"
@click="apply"
>
Apply {{ selectedSlugs.length }} Field{{ selectedSlugs.length !== 1 ? 's' : '' }}
</ModButton>
</div>
</template>
</ModCard>
</template>
3. AI Translation Fields
Backend Translation Service
<?php
namespace App\Services\AttendeeField;
use App\Models\AttendeeField;
use App\Models\AttendeeFieldTranslation;
use App\Models\Attendee;
use Google\Cloud\Translate\V2\TranslateClient;
use Illuminate\Support\Facades\Cache;
class FieldTranslationService
{
public function __construct(
protected TranslateClient $translateClient,
) {}
/**
* Get translated value for an attendee field
*/
public function getTranslatedValue(
Attendee $attendee,
AttendeeField $field
): ?string {
$translation = $field->translation;
if (!$translation) {
return null;
}
// Get source field value
$sourceField = $translation->sourceField;
$sourceValue = $attendee->attendee_fields[$sourceField->slug] ?? null;
if (!$sourceValue) {
return null;
}
// Check cache
$cacheKey = $this->getCacheKey($field->id, $sourceValue);
if ($translation->cache_translations) {
$cached = Cache::get($cacheKey);
if ($cached !== null) {
return $cached;
}
}
// Perform translation
$translatedValue = match ($translation->translation_type) {
'language' => $this->translateLanguage($sourceValue, $translation),
'format' => $this->transformFormat($sourceValue, $translation),
'ai_transform' => $this->aiTransform($sourceValue, $translation, $attendee),
default => $sourceValue,
};
// Cache result
if ($translation->cache_translations && $translatedValue) {
Cache::put(
$cacheKey,
$translatedValue,
now()->addHours($translation->cache_ttl_hours)
);
}
return $translatedValue;
}
/**
* Translate between languages using Google Translate
*/
protected function translateLanguage(
string $value,
AttendeeFieldTranslation $config
): string {
$options = [
'target' => $config->target_language,
];
if ($config->source_language && $config->source_language !== 'auto') {
$options['source'] = $config->source_language;
}
$result = $this->translateClient->translate($value, $options);
return $result['text'];
}
/**
* Transform value format (dates, numbers, etc.)
*/
protected function transformFormat(
string $value,
AttendeeFieldTranslation $config
): string {
// Get format configuration from transformation_prompt
$formatConfig = json_decode($config->transformation_prompt, true);
if (!$formatConfig) {
return $value;
}
return match ($formatConfig['type'] ?? null) {
'date' => $this->formatDate($value, $formatConfig),
'number' => $this->formatNumber($value, $formatConfig),
'phone' => $this->formatPhone($value, $formatConfig),
'uppercase' => strtoupper($value),
'lowercase' => strtolower($value),
'titlecase' => ucwords(strtolower($value)),
default => $value,
};
}
/**
* AI-powered transformation using Vertex AI
*/
protected function aiTransform(
string $value,
AttendeeFieldTranslation $config,
Attendee $attendee
): string {
if (!$config->ai_interface_id) {
return $value;
}
$aiInterface = $config->aiInterface;
if (!$aiInterface) {
return $value;
}
// Build prompt with context
$prompt = str_replace(
['{value}', '{attendee_name}', '{attendee_email}'],
[$value, $attendee->first_name . ' ' . $attendee->last_name, $attendee->contact_email],
$config->transformation_prompt
);
// Call AI service
$aiService = app(AiInterfaceService::class);
$response = $aiService->generateText($aiInterface, $prompt);
return trim($response);
}
protected function getCacheKey(int $fieldId, string $sourceValue): string
{
return "field_translation:{$fieldId}:" . md5($sourceValue);
}
protected function formatDate(string $value, array $config): string
{
try {
$date = new \DateTime($value);
return $date->format($config['output_format'] ?? 'Y-m-d');
} catch (\Exception $e) {
return $value;
}
}
protected function formatNumber(string $value, array $config): string
{
$number = floatval($value);
return number_format(
$number,
$config['decimals'] ?? 0,
$config['decimal_separator'] ?? '.',
$config['thousands_separator'] ?? ','
);
}
protected function formatPhone(string $value, array $config): string
{
// Basic phone formatting
$digits = preg_replace('/\D/', '', $value);
$format = $config['format'] ?? '(###) ###-####';
$result = '';
$digitIndex = 0;
for ($i = 0; $i < strlen($format); $i++) {
if ($format[$i] === '#' && $digitIndex < strlen($digits)) {
$result .= $digits[$digitIndex++];
} else {
$result .= $format[$i];
}
}
return $result;
}
}
Frontend Translation Configuration
<!-- resources/js/Components/Attendee/FieldTranslationConfig.vue -->
<script setup>
import { ref, computed, watch } from 'vue'
import ModCard from '@/Components/Mod/v2/Cards/ModCard.vue'
import ModSelect from '@/Components/Mod/v2/Elements/Selects/ModSelect.vue'
import ModInput from '@/Components/Mod/v2/Elements/Inputs/ModInput.vue'
import ModTextarea from '@/Components/Mod/v2/Elements/Inputs/ModTextarea.vue'
import ModSwitch from '@/Components/Mod/v2/Elements/Boolean/ModSwitch.vue'
const props = defineProps({
modelValue: { type: Object, default: null },
availableFields: { type: Array, default: () => [] },
aiInterfaces: { type: Array, default: () => [] },
currentFieldId: { type: [Number, String], required: true },
})
const emit = defineEmits(['update:modelValue'])
const config = ref(props.modelValue || {
source_field_id: null,
translation_type: 'language',
source_language: 'auto',
target_language: 'en',
ai_interface_id: null,
transformation_prompt: '',
cache_translations: true,
cache_ttl_hours: 24,
})
watch(config, (newVal) => {
emit('update:modelValue', newVal)
}, { deep: true })
const sourceFieldOptions = computed(() =>
props.availableFields
.filter(f => f.id !== props.currentFieldId)
.map(f => ({
value: f.id,
label: f.name,
description: f.slug,
}))
)
const translationTypeOptions = [
{ value: 'language', label: 'Language Translation', description: 'Translate to another language' },
{ value: 'format', label: 'Format Transformation', description: 'Change format (date, number, etc.)' },
{ value: 'ai_transform', label: 'AI Transformation', description: 'Custom AI-powered transformation' },
]
const languageOptions = [
{ value: 'auto', label: 'Auto-detect' },
{ value: 'en', label: 'English' },
{ value: 'es', label: 'Spanish' },
{ value: 'fr', label: 'French' },
{ value: 'de', label: 'German' },
{ value: 'zh', label: 'Chinese' },
{ value: 'ja', label: 'Japanese' },
{ value: 'ko', label: 'Korean' },
{ value: 'pt', label: 'Portuguese' },
{ value: 'ar', label: 'Arabic' },
// ... more languages
]
const aiInterfaceOptions = computed(() =>
props.aiInterfaces.map(ai => ({
value: ai.id,
label: ai.name,
description: ai.provider,
}))
)
</script>
<template>
<ModCard
title="Translation Configuration"
icon="language"
collapsible
:collapsed="!modelValue"
>
<div class="row g-3">
<!-- Source Field -->
<div class="col-md-6">
<ModSelect
v-model="config.source_field_id"
label="Source Field"
:options="sourceFieldOptions"
placeholder="Select field to translate from..."
required
/>
</div>
<!-- Translation Type -->
<div class="col-md-6">
<ModSelect
v-model="config.translation_type"
label="Translation Type"
:options="translationTypeOptions"
required
/>
</div>
<!-- Language Translation Options -->
<template v-if="config.translation_type === 'language'">
<div class="col-md-6">
<ModSelect
v-model="config.source_language"
label="Source Language"
:options="languageOptions"
/>
</div>
<div class="col-md-6">
<ModSelect
v-model="config.target_language"
label="Target Language"
:options="languageOptions.filter(l => l.value !== 'auto')"
required
/>
</div>
</template>
<!-- Format Transformation Options -->
<template v-if="config.translation_type === 'format'">
<div class="col-12">
<ModTextarea
v-model="config.transformation_prompt"
label="Format Configuration (JSON)"
placeholder='{"type": "date", "output_format": "F j, Y"}'
rows="3"
/>
<small class="text-muted">
Supported types: date, number, phone, uppercase, lowercase, titlecase
</small>
</div>
</template>
<!-- AI Transformation Options -->
<template v-if="config.translation_type === 'ai_transform'">
<div class="col-md-6">
<ModSelect
v-model="config.ai_interface_id"
label="AI Interface"
:options="aiInterfaceOptions"
placeholder="Select AI interface..."
required
/>
</div>
<div class="col-12">
<ModTextarea
v-model="config.transformation_prompt"
label="Transformation Prompt"
placeholder="Transform the following value: {value}..."
rows="4"
/>
<small class="text-muted">
Available variables: {value}, {attendee_name}, {attendee_email}
</small>
</div>
</template>
<!-- Caching Options -->
<div class="col-md-6">
<ModSwitch
v-model="config.cache_translations"
label="Cache Translations"
/>
</div>
<div v-if="config.cache_translations" class="col-md-6">
<ModInput
v-model.number="config.cache_ttl_hours"
type="number"
label="Cache Duration (hours)"
min="1"
max="720"
/>
</div>
</div>
</ModCard>
</template>
4. Password Authentication Configuration
ShowPage Tab for Password Config
// In AttendeeType Show.vue
const passwordConfigCard = {
type: 'fields_list',
title: 'Password Authentication',
icon: 'lock',
description: 'Configure password-based login for this attendee type',
fieldsList: [
{
type: 'boolean',
style: 'switch',
name: 'password_config.password_auth_enabled',
label: 'Enable Password Authentication',
colsMd: 12,
},
{
type: 'option-select',
style: 'select',
name: 'password_config.username_field_slug',
label: 'Username Field',
description: 'Field to use as login username',
options: attendeeFieldsForUsername,
condition: {
field: 'password_config.password_auth_enabled',
operator: '==',
value: true,
},
colsMd: 6,
},
{
type: 'display',
style: 'heading',
contentType: 'heading-small',
content: 'Password Requirements',
condition: {
field: 'password_config.password_auth_enabled',
operator: '==',
value: true,
},
colsMd: 12,
},
{
type: 'input',
style: 'number',
name: 'password_config.min_length',
label: 'Minimum Length',
default: 8,
min: 6,
max: 32,
condition: {
field: 'password_config.password_auth_enabled',
operator: '==',
value: true,
},
colsMd: 3,
},
{
type: 'input',
style: 'number',
name: 'password_config.max_length',
label: 'Maximum Length',
default: 128,
min: 16,
max: 256,
condition: {
field: 'password_config.password_auth_enabled',
operator: '==',
value: true,
},
colsMd: 3,
},
{
type: 'boolean',
style: 'checkbox',
name: 'password_config.require_uppercase',
label: 'Require Uppercase Letter',
default: true,
condition: {
field: 'password_config.password_auth_enabled',
operator: '==',
value: true,
},
colsMd: 3,
},
{
type: 'boolean',
style: 'checkbox',
name: 'password_config.require_lowercase',
label: 'Require Lowercase Letter',
default: true,
condition: {
field: 'password_config.password_auth_enabled',
operator: '==',
value: true,
},
colsMd: 3,
},
{
type: 'boolean',
style: 'checkbox',
name: 'password_config.require_number',
label: 'Require Number',
default: true,
condition: {
field: 'password_config.password_auth_enabled',
operator: '==',
value: true,
},
colsMd: 3,
},
{
type: 'boolean',
style: 'checkbox',
name: 'password_config.require_special',
label: 'Require Special Character',
default: false,
condition: {
field: 'password_config.password_auth_enabled',
operator: '==',
value: true,
},
colsMd: 3,
},
{
type: 'display',
style: 'heading',
contentType: 'heading-small',
content: 'Security Settings',
condition: {
field: 'password_config.password_auth_enabled',
operator: '==',
value: true,
},
colsMd: 12,
},
{
type: 'input',
style: 'number',
name: 'password_config.max_attempts',
label: 'Max Login Attempts',
description: 'Before account lockout',
default: 5,
min: 3,
max: 10,
condition: {
field: 'password_config.password_auth_enabled',
operator: '==',
value: true,
},
colsMd: 4,
},
{
type: 'input',
style: 'number',
name: 'password_config.lockout_duration',
label: 'Lockout Duration (seconds)',
default: 900,
min: 60,
max: 86400,
condition: {
field: 'password_config.password_auth_enabled',
operator: '==',
value: true,
},
colsMd: 4,
},
{
type: 'input',
style: 'number',
name: 'password_config.password_expiry_days',
label: 'Password Expiry (days)',
description: 'Leave empty for no expiry',
placeholder: 'Never expires',
condition: {
field: 'password_config.password_auth_enabled',
operator: '==',
value: true,
},
colsMd: 4,
},
],
}
5. Enhanced Validation Configuration
Validation Rules Builder Component
<!-- resources/js/Components/Attendee/ValidationRulesBuilder.vue -->
<script setup>
import { ref, computed, watch } from 'vue'
import ModSelect from '@/Components/Mod/v2/Elements/Selects/ModSelect.vue'
import ModInput from '@/Components/Mod/v2/Elements/Inputs/ModInput.vue'
import ModSwitch from '@/Components/Mod/v2/Elements/Boolean/ModSwitch.vue'
import ModButton from '@/Components/Mod/v2/Elements/ModButton.vue'
const props = defineProps({
modelValue: { type: Object, default: null },
fieldType: { type: String, default: 'text' },
})
const emit = defineEmits(['update:modelValue'])
// Available rules based on field type
const availableRules = computed(() => {
const common = [
{ key: 'required', label: 'Required', hasValue: false },
{ key: 'nullable', label: 'Nullable', hasValue: false },
]
const typeSpecific = {
text: [
{ key: 'min', label: 'Min Length', hasValue: true, valueType: 'number' },
{ key: 'max', label: 'Max Length', hasValue: true, valueType: 'number' },
{ key: 'regex', label: 'Regex Pattern', hasValue: true, valueType: 'text' },
{ key: 'alpha', label: 'Letters Only', hasValue: false },
{ key: 'alpha_num', label: 'Letters & Numbers', hasValue: false },
],
email: [
{ key: 'email', label: 'Valid Email', hasValue: false },
{ key: 'unique', label: 'Unique', hasValue: true, valueType: 'table' },
],
number: [
{ key: 'numeric', label: 'Numeric', hasValue: false },
{ key: 'integer', label: 'Integer', hasValue: false },
{ key: 'min', label: 'Min Value', hasValue: true, valueType: 'number' },
{ key: 'max', label: 'Max Value', hasValue: true, valueType: 'number' },
{ key: 'between', label: 'Between', hasValue: true, valueType: 'range' },
],
date: [
{ key: 'date', label: 'Valid Date', hasValue: false },
{ key: 'after', label: 'After Date', hasValue: true, valueType: 'date' },
{ key: 'before', label: 'Before Date', hasValue: true, valueType: 'date' },
{ key: 'after_or_equal', label: 'After or Equal', hasValue: true, valueType: 'date' },
],
file: [
{ key: 'file', label: 'Valid File', hasValue: false },
{ key: 'mimes', label: 'Allowed Types', hasValue: true, valueType: 'text' },
{ key: 'max', label: 'Max Size (KB)', hasValue: true, valueType: 'number' },
],
select: [
{ key: 'in', label: 'In Options', hasValue: false },
],
}
return [...common, ...(typeSpecific[props.fieldType] || [])]
})
const rules = ref(parseRules(props.modelValue))
function parseRules(value) {
if (!value) return []
if (typeof value === 'string') {
return value.split('|').map(rule => {
const [key, val] = rule.split(':')
return { key, value: val || null }
})
}
if (Array.isArray(value)) {
return value.map(rule => {
if (typeof rule === 'string') {
const [key, val] = rule.split(':')
return { key, value: val || null }
}
return rule
})
}
return []
}
function formatRules() {
return rules.value
.filter(r => r.key)
.map(r => r.value ? `${r.key}:${r.value}` : r.key)
}
watch(rules, () => {
emit('update:modelValue', formatRules())
}, { deep: true })
const addRule = () => {
rules.value.push({ key: '', value: null })
}
const removeRule = (index) => {
rules.value.splice(index, 1)
}
const getRuleConfig = (key) => {
return availableRules.value.find(r => r.key === key)
}
</script>
<template>
<div class="validation-rules-builder">
<label class="form-label">Validation Rules</label>
<div
v-for="(rule, index) in rules"
:key="index"
class="d-flex gap-2 mb-2 align-items-start"
>
<ModSelect
v-model="rule.key"
:options="availableRules.map(r => ({ value: r.key, label: r.label }))"
placeholder="Select rule..."
class="flex-grow-1"
size="sm"
/>
<template v-if="getRuleConfig(rule.key)?.hasValue">
<ModInput
v-if="getRuleConfig(rule.key)?.valueType === 'number'"
v-model.number="rule.value"
type="number"
placeholder="Value"
class="w-auto"
size="sm"
style="max-width: 100px;"
/>
<ModInput
v-else-if="getRuleConfig(rule.key)?.valueType === 'date'"
v-model="rule.value"
type="date"
class="w-auto"
size="sm"
/>
<ModInput
v-else
v-model="rule.value"
type="text"
placeholder="Value"
class="w-auto"
size="sm"
style="max-width: 150px;"
/>
</template>
<ModButton
color="danger"
outline
size="sm"
@click="removeRule(index)"
>
<ModIcon icon="times" />
</ModButton>
</div>
<ModButton
color="secondary"
outline
size="sm"
@click="addRule"
>
<ModIcon icon="plus" class="me-1" />
Add Rule
</ModButton>
<div v-if="rules.length > 0" class="mt-2">
<small class="text-muted">
Preview: <code>{{ formatRules().join('|') }}</code>
</small>
</div>
</div>
</template>
API Endpoints
Suggested Fields API
// routes/api/v1.php
Route::prefix('projects/{project}')->group(function () {
Route::get('suggested-fields/lookup', [SuggestedFieldController::class, 'lookup']);
Route::get('suggested-fields/templates', [SuggestedFieldController::class, 'templates']);
Route::post('suggested-fields/apply', [SuggestedFieldController::class, 'apply']);
});
// Super Admin routes
Route::prefix('admin/suggested-field-templates')->group(function () {
Route::get('/', [SuggestedFieldTemplateController::class, 'index']);
Route::post('/', [SuggestedFieldTemplateController::class, 'store']);
Route::get('{template}', [SuggestedFieldTemplateController::class, 'show']);
Route::put('{template}', [SuggestedFieldTemplateController::class, 'update']);
Route::delete('{template}', [SuggestedFieldTemplateController::class, 'destroy']);
Route::post('{template}/items', [SuggestedFieldTemplateController::class, 'addItem']);
Route::put('{template}/items/{item}', [SuggestedFieldTemplateController::class, 'updateItem']);
Route::delete('{template}/items/{item}', [SuggestedFieldTemplateController::class, 'removeItem']);
});
Translation Fields API
Route::prefix('attendee-fields/{field}')->group(function () {
Route::get('translation', [AttendeeFieldTranslationController::class, 'show']);
Route::put('translation', [AttendeeFieldTranslationController::class, 'update']);
Route::delete('translation', [AttendeeFieldTranslationController::class, 'destroy']);
Route::post('translation/test', [AttendeeFieldTranslationController::class, 'test']);
});
Next Steps
- 04-REGISTRATION-FORMS.md - Registration form type implementation
- 05-QUIZ-FORMS.md - Quiz form type with gamification