-
Notifications
You must be signed in to change notification settings - Fork 93
Description
Uganda, Niue & Cook Islands all take advantage of page conditionals.
Describe the bug
If you add a page conditional to a form, it can combined with field conditionals causing hidden fields to still be considered as visible in data that is submitted to the backend.
In uganda, there was a page conditional that hid the parent's page if the child was a FOUNDLING. The age field conditional seemed to combine with this in such a way, that even though the age field was hidden, data for the field such as asOfDate was submitted.
There is an assumption with the conditionals that it's like an or. So if you have multiple SHOW conditionals, if any of them resolves to "true" the field would get shown. In this case, as the "page" SHOW conditional resolves to "true", the field is considered to not be hidden.
To reproduce
Configure a page conditional like this:
export const father = defineFormPage({
id: 'father',
title: {
defaultMessage: "Father's details",
description: 'Form section title for fathers details',
id: 'form.section.father.title'
},
conditional: not(
field('child.placeOfBirth').isEqualTo(PlaceOfBirth.FOUNDLING)
),
Then an age field like this, as we have it in Farajaland:
{
id: 'father.age',
type: FieldType.AGE,
analytics: true,
required: true,
label: {
defaultMessage: 'Age of father',
description: 'This is the label for the field',
id: 'event.birth.action.declare.form.section.father.field.age.label'
},
configuration: {
asOfDate: field('child.dob'),
postfix: {
defaultMessage: 'years',
description: 'This is the postfix for age field',
id: 'event.birth.action.declare.form.section.person.field.age.postfix'
}
},
conditionals: [
{
type: ConditionalType.SHOW,
conditional: and(
field('father.dobUnknown').isEqualTo(true),
requireFatherDetails
)
}
],
validation: [
{
validator: field('father.age').asAge().isBetween(12, 120),
message: {
defaultMessage: 'Age must be between 12 and 120',
description: 'Error message for invalid age',
id: 'event.action.declare.form.section.person.field.age.error'
}
}
]
},
Notice that the registration will not submit to the backend with this error:
{
"error": {
"json": {
"message": "[{\"message\":\"Hidden or disabled field should not receive a value\",\"id\":\"mother.age\",\"value\":{\"asOfDate\":\"2025-10-22\"}},{\"message\":\"Hidden or disabled field should not receive a value\",\"id\":\"father.age\",\"value\":{\"asOfDate\":\"2025-10-22\"}}]",
If you log like this in getConditionalActionsForField you can see the bug:
if (field.id == 'father.age') {
field.conditionals.forEach((conditional) => {
console.log('conditional.conditional: ', conditional.conditional)
console.log('values: ', values)
console.log('output: ', validate(conditional.conditional, values))
})
}
Metadata
Metadata
Assignees
Labels
Type
Projects
Status