feat(form-builder): FormFieldValidationRuleService + legacy backfill + snapshot + library row-copy
This commit is contained in:
@@ -308,9 +308,12 @@ final class FormBuilderDevSeeder
|
||||
'slug' => 'sectie_voorkeur',
|
||||
'label' => 'Bij welke sectie wil je het liefst werken?',
|
||||
'help_text' => 'Sleep je voorkeuren in volgorde. Nummer 1 is je eerste keuze.',
|
||||
// UI soft cap; the hard cap of 5 lives in
|
||||
// FormValueService shape validation.
|
||||
'validation_rules' => ['max_priorities' => 3],
|
||||
// UI soft cap (hard cap of 5 is in FormValueService shape
|
||||
// validation). Post-WS-5b the UI cap lives as a relational
|
||||
// row with rule_type `max_selected` — see
|
||||
// seedEventRegistrationShowcaseSchema() which populates it
|
||||
// via FormFieldValidationRuleService.
|
||||
'max_selected_ui_cap' => 3,
|
||||
'is_required' => false,
|
||||
'is_filterable' => false,
|
||||
'display_width' => 'full',
|
||||
@@ -357,8 +360,10 @@ final class FormBuilderDevSeeder
|
||||
'version' => 1,
|
||||
]);
|
||||
|
||||
$ruleService = app(\App\Services\FormBuilder\FormFieldValidationRuleService::class);
|
||||
|
||||
foreach (self::showcaseFieldDefinitions() as $sortOrder => $def) {
|
||||
FormField::create([
|
||||
$field = FormField::create([
|
||||
'form_schema_id' => $schema->id,
|
||||
'field_type' => $def['type']->value,
|
||||
'slug' => $def['slug'],
|
||||
@@ -376,6 +381,16 @@ final class FormBuilderDevSeeder
|
||||
'value_storage_hint' => $def['value_storage_hint'] ?? FormValueStorageHint::JSON,
|
||||
'sort_order' => $sortOrder + 1,
|
||||
]);
|
||||
|
||||
// Relational validation rules (WS-5b). The SECTION_PRIORITY
|
||||
// field carries the UI soft cap as a `max_selected` row; other
|
||||
// fields in the showcase have no rules yet.
|
||||
if (isset($def['max_selected_ui_cap'])) {
|
||||
$ruleService->replaceRules($field, [[
|
||||
'rule_type' => \App\Enums\FormBuilder\FormFieldValidationRuleType::MaxSelected->value,
|
||||
'parameters' => ['value' => (int) $def['max_selected_ui_cap']],
|
||||
]]);
|
||||
}
|
||||
}
|
||||
|
||||
return $schema->refresh();
|
||||
|
||||
Reference in New Issue
Block a user