Skip to content

collectDataFields

collectDataFields(nodes, data): (InputField | TextareaField | NumberField | ChoiceField)[]

Depth-first walk of a node tree, flattened to the data-carrying fields that are currently visible given data — a Fieldset/Row is walked through unconditionally, but a Variant contributes only its currently-selected branch’s fields, so a field inside a branch that isn’t shown never gets treated as present or required.

data is required, not optional, deliberately: a caller that doesn’t have the respondent’s current answers yet has no correct default to fall back to (an empty object would make every Variant resolve as if nothing had been answered, which is only sometimes what a caller wants).

FormNode[]

SubmissionData

(InputField | TextareaField | NumberField | ChoiceField)[]