Skip to content

Fields inside <Conditional> do not immediately populate in validator object #62

@etoler1841

Description

@etoler1841

Fields placed inside a <Conditional> only populate in the validator object after another field is modified.

const formValidator = v => {
  console.log(v)
  // Validation
}

<Formol onSubmit={doFormStuff} validator={formValidator}>
  <Field name="yesOrNo" type="radio-set" choices={['Yes', 'No']}>Yes or no?</Field>
  <Conditional show={({ yesOrNo }) => yesOrNo === 'No'}>
    <Field name="whyNot">Really? Why not?</Field>
  </Conditional>
  <Field name="anotherField">Another field</Field>
</Formol>

After choosing "no," the object should be { yesOrNo: 'No', whyNot: null, anotherField: null }. Instead, the resulting object is just { yesOrNo: 'No', anotherField: null }. Even submitting the form won't cause the key to populate; it only shows up after changing "Another field."

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions