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;
|
||||
@@ -40,6 +41,7 @@ final class RegistrationFormField extends Model
|
||||
'section',
|
||||
'help_text',
|
||||
'sort_order',
|
||||
'display_width',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
@@ -52,6 +54,7 @@ final class RegistrationFormField extends Model
|
||||
'is_admin_only' => 'boolean',
|
||||
'is_filterable' => 'boolean',
|
||||
'sort_order' => 'integer',
|
||||
'display_width' => FieldDisplayWidth::class,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -65,6 +68,25 @@ final class RegistrationFormField extends Model
|
||||
return $this->hasMany(PersonFieldValue::class, 'registration_form_field_id');
|
||||
}
|
||||
|
||||
/** @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 isMultiValue(): bool
|
||||
{
|
||||
return $this->field_type->isMultiValue();
|
||||
|
||||
Reference in New Issue
Block a user