feat: registration form field display_width and option descriptions
Add configurable column widths (full/half) and optional descriptions for radio/select/checkbox options on registration form fields. - Migration adds display_width column to both tables - FieldDisplayWidth enum with smart defaults per field type - normalized_options accessor for backwards-compatible option format - Portal form renderer uses display_width for VRow/VCol grid layout - Radio/select/checkbox options render with descriptions - Admin field editor supports display_width toggle and description input - System templates updated with appropriate widths and descriptions Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\FieldDisplayWidth;
|
||||
use App\Enums\RegistrationFieldType;
|
||||
use App\Models\Scopes\OrganisationScope;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
@@ -36,6 +37,7 @@ final class RegistrationFieldTemplate extends Model
|
||||
'section',
|
||||
'help_text',
|
||||
'sort_order',
|
||||
'display_width',
|
||||
'is_system',
|
||||
'is_active',
|
||||
];
|
||||
@@ -50,11 +52,31 @@ final class RegistrationFieldTemplate extends Model
|
||||
'is_portal_visible' => 'boolean',
|
||||
'is_admin_only' => 'boolean',
|
||||
'sort_order' => 'integer',
|
||||
'display_width' => FieldDisplayWidth::class,
|
||||
'is_system' => 'boolean',
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
/** @return array<int, array{label: string, description: string|null}>|null */
|
||||
public function getNormalizedOptionsAttribute(): ?array
|
||||
{
|
||||
if ($this->options === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return collect($this->options)->map(function (mixed $option): array {
|
||||
if (is_string($option)) {
|
||||
return ['label' => $option, 'description' => null];
|
||||
}
|
||||
|
||||
return [
|
||||
'label' => $option['label'] ?? (string) $option,
|
||||
'description' => $option['description'] ?? null,
|
||||
];
|
||||
})->toArray();
|
||||
}
|
||||
|
||||
public function organisation(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Organisation::class);
|
||||
|
||||
Reference in New Issue
Block a user