diff --git a/src/components/FormField/FormField.tsx b/src/components/FormField/FormField.tsx index 9d4ee52aa5..49694d2eb8 100644 --- a/src/components/FormField/FormField.tsx +++ b/src/components/FormField/FormField.tsx @@ -80,8 +80,13 @@ const FormField = ({ hasError('custom') const isOptional = !options?.validators?.some((validator: any) => { + // Check if validator is a function with the name 'required' + // If so, it also isn't optional + if (validator.name === 'required') return true + return ['required', 'min'].includes(validator) }) + const FieldSetWrapper = isFieldSet ? FieldSet : Fragment return ( diff --git a/src/signals/incident/definitions/wizard-step-2-vulaan/afval-container.ts b/src/signals/incident/definitions/wizard-step-2-vulaan/afval-container.ts index d868eae5e7..d1223a83fe 100644 --- a/src/signals/incident/definitions/wizard-step-2-vulaan/afval-container.ts +++ b/src/signals/incident/definitions/wizard-step-2-vulaan/afval-container.ts @@ -134,7 +134,7 @@ export const controls = { }, render: QuestionFieldType.AssetSelect, options: { - validators: [validateObjectLocation('container'), 'required'], + validators: [validateObjectLocation('container')], }, }, } diff --git a/src/signals/incident/definitions/wizard-step-2-vulaan/straatverlichting-klokken.ts b/src/signals/incident/definitions/wizard-step-2-vulaan/straatverlichting-klokken.ts index 4024334829..a7e2dafce1 100644 --- a/src/signals/incident/definitions/wizard-step-2-vulaan/straatverlichting-klokken.ts +++ b/src/signals/incident/definitions/wizard-step-2-vulaan/straatverlichting-klokken.ts @@ -143,7 +143,7 @@ const straatverlichtingKlokken = { }, render: QuestionFieldType.StreetlightSelect, options: { - validators: [validateObjectLocation('lichtpunt'), 'required'], + validators: [validateObjectLocation('lichtpunt')], }, }, @@ -294,7 +294,7 @@ const straatverlichtingKlokken = { }, render: QuestionFieldType.ClockSelect, options: { - validators: [validateObjectLocation('klok'), 'required'], + validators: [validateObjectLocation('klok')], }, },