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:
@@ -97,10 +97,12 @@ final class PublicRegistrationDataController extends Controller
|
||||
'slug' => $field->slug,
|
||||
'field_type' => $field->field_type->value,
|
||||
'options' => $field->options,
|
||||
'normalized_options' => $field->normalized_options,
|
||||
'tag_category' => $field->tag_category,
|
||||
'is_required' => $field->is_required,
|
||||
'section' => $field->section,
|
||||
'help_text' => $field->help_text,
|
||||
'display_width' => $field->display_width->value,
|
||||
];
|
||||
|
||||
if ($field->field_type === \App\Enums\RegistrationFieldType::TAG_PICKER) {
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Requests\Api\V1;
|
||||
|
||||
use App\Enums\FieldDisplayWidth;
|
||||
use App\Enums\RegistrationFieldType;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
@@ -29,7 +30,9 @@ final class StoreRegistrationFieldTemplateRequest extends FormRequest
|
||||
$type?->prohibitsOptions() ? 'prohibited' : 'nullable',
|
||||
'array',
|
||||
],
|
||||
'options.*' => ['string', 'max:255'],
|
||||
'options.*' => ['required'],
|
||||
'options.*.label' => ['required_if:options.*,array', 'string', 'max:255'],
|
||||
'options.*.description' => ['nullable', 'string', 'max:200'],
|
||||
'tag_category' => [
|
||||
$type === RegistrationFieldType::TAG_PICKER ? 'nullable' : 'prohibited',
|
||||
'string',
|
||||
@@ -42,6 +45,7 @@ final class StoreRegistrationFieldTemplateRequest extends FormRequest
|
||||
'section' => ['nullable', 'string', 'max:100'],
|
||||
'help_text' => ['nullable', 'string', 'max:5000'],
|
||||
'sort_order' => ['nullable', 'integer', 'min:0'],
|
||||
'display_width' => ['sometimes', Rule::in(array_column(FieldDisplayWidth::cases(), 'value'))],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Requests\Api\V1;
|
||||
|
||||
use App\Enums\FieldDisplayWidth;
|
||||
use App\Enums\RegistrationFieldType;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
@@ -29,7 +30,9 @@ final class StoreRegistrationFormFieldRequest extends FormRequest
|
||||
$type?->prohibitsOptions() ? 'prohibited' : 'nullable',
|
||||
'array',
|
||||
],
|
||||
'options.*' => ['string', 'max:255'],
|
||||
'options.*' => ['required'],
|
||||
'options.*.label' => ['required_if:options.*,array', 'string', 'max:255'],
|
||||
'options.*.description' => ['nullable', 'string', 'max:200'],
|
||||
'tag_category' => [
|
||||
$type === RegistrationFieldType::TAG_PICKER ? 'nullable' : 'prohibited',
|
||||
'string',
|
||||
@@ -42,6 +45,7 @@ final class StoreRegistrationFormFieldRequest extends FormRequest
|
||||
'section' => ['nullable', 'string', 'max:100'],
|
||||
'help_text' => ['nullable', 'string', 'max:5000'],
|
||||
'sort_order' => ['nullable', 'integer', 'min:0'],
|
||||
'display_width' => ['sometimes', Rule::in(array_column(FieldDisplayWidth::cases(), 'value'))],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Requests\Api\V1;
|
||||
|
||||
use App\Enums\FieldDisplayWidth;
|
||||
use App\Enums\RegistrationFieldType;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
final class UpdateRegistrationFieldTemplateRequest extends FormRequest
|
||||
{
|
||||
@@ -20,7 +22,9 @@ final class UpdateRegistrationFieldTemplateRequest extends FormRequest
|
||||
return [
|
||||
'label' => ['sometimes', 'string', 'max:255'],
|
||||
'options' => ['nullable', 'array'],
|
||||
'options.*' => ['string', 'max:255'],
|
||||
'options.*' => ['required'],
|
||||
'options.*.label' => ['required_if:options.*,array', 'string', 'max:255'],
|
||||
'options.*.description' => ['nullable', 'string', 'max:200'],
|
||||
'tag_category' => ['nullable', 'string', 'max:50'],
|
||||
'is_required' => ['nullable', 'boolean'],
|
||||
'is_filterable' => ['nullable', 'boolean'],
|
||||
@@ -29,6 +33,7 @@ final class UpdateRegistrationFieldTemplateRequest extends FormRequest
|
||||
'section' => ['nullable', 'string', 'max:100'],
|
||||
'help_text' => ['nullable', 'string', 'max:5000'],
|
||||
'sort_order' => ['nullable', 'integer', 'min:0'],
|
||||
'display_width' => ['sometimes', Rule::in(array_column(FieldDisplayWidth::cases(), 'value'))],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Requests\Api\V1;
|
||||
|
||||
use App\Enums\FieldDisplayWidth;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
final class UpdateRegistrationFormFieldRequest extends FormRequest
|
||||
{
|
||||
@@ -19,7 +21,9 @@ final class UpdateRegistrationFormFieldRequest extends FormRequest
|
||||
return [
|
||||
'label' => ['sometimes', 'string', 'max:255'],
|
||||
'options' => ['nullable', 'array'],
|
||||
'options.*' => ['string', 'max:255'],
|
||||
'options.*' => ['required'],
|
||||
'options.*.label' => ['required_if:options.*,array', 'string', 'max:255'],
|
||||
'options.*.description' => ['nullable', 'string', 'max:200'],
|
||||
'tag_category' => ['nullable', 'string', 'max:50'],
|
||||
'is_required' => ['nullable', 'boolean'],
|
||||
'is_portal_visible' => ['nullable', 'boolean'],
|
||||
@@ -28,6 +32,7 @@ final class UpdateRegistrationFormFieldRequest extends FormRequest
|
||||
'section' => ['nullable', 'string', 'max:100'],
|
||||
'help_text' => ['nullable', 'string', 'max:5000'],
|
||||
'sort_order' => ['nullable', 'integer', 'min:0'],
|
||||
'display_width' => ['sometimes', Rule::in(array_column(FieldDisplayWidth::cases(), 'value'))],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ final class RegistrationFieldTemplateResource extends JsonResource
|
||||
'slug' => $this->slug,
|
||||
'field_type' => $this->field_type->value,
|
||||
'options' => $this->options,
|
||||
'normalized_options' => $this->normalized_options,
|
||||
'tag_category' => $this->tag_category,
|
||||
'is_required' => $this->is_required,
|
||||
'is_filterable' => $this->is_filterable,
|
||||
@@ -26,6 +27,7 @@ final class RegistrationFieldTemplateResource extends JsonResource
|
||||
'section' => $this->section,
|
||||
'help_text' => $this->help_text,
|
||||
'sort_order' => $this->sort_order,
|
||||
'display_width' => $this->display_width->value,
|
||||
'is_system' => $this->is_system,
|
||||
'is_active' => $this->is_active,
|
||||
'created_at' => $this->created_at->toIso8601String(),
|
||||
|
||||
@@ -20,6 +20,7 @@ final class RegistrationFormFieldResource extends JsonResource
|
||||
'slug' => $this->slug,
|
||||
'field_type' => $this->field_type->value,
|
||||
'options' => $this->options,
|
||||
'normalized_options' => $this->normalized_options,
|
||||
'tag_category' => $this->tag_category,
|
||||
'is_required' => $this->is_required,
|
||||
'is_portal_visible' => $this->is_portal_visible,
|
||||
@@ -28,6 +29,7 @@ final class RegistrationFormFieldResource extends JsonResource
|
||||
'section' => $this->section,
|
||||
'help_text' => $this->help_text,
|
||||
'sort_order' => $this->sort_order,
|
||||
'display_width' => $this->display_width->value,
|
||||
'created_at' => $this->created_at->toIso8601String(),
|
||||
'updated_at' => $this->updated_at->toIso8601String(),
|
||||
'available_tags' => $this->when(
|
||||
|
||||
Reference in New Issue
Block a user