Skip to content

Select is not working with controlled component;  #130

Open
@Vedant-LC

Description

@Vedant-LC

Select is not working with controlled component;

Cannot Retrieve the form.watch values in fieldtype='select'
however form.watch works when fieldtype='string' for same schema, and select field is not able to detect inital values ( passed from component not schema )

Schema

export enum DesignEnum {
    RCT = "RCT"

}

export const StudyDesign = z.object({
    Design: z.nativeEnum(DesignEnum).optional().describe("Type of study design"),
    "Type of RCT": z
        .enum(["Parallel", "Cross-over", "Factorial", "Cluster", "Stepped wedge"])
        .optional()
        .describe("Type of randomized controlled trial"),
    Blinding: z
        .enum(["Open label", "Single Blind", "Double Blind", "Triple"])
        .optional()
        .describe("Blinding method used in the study"),
})

Auto-form component

  <AutoForm schema={schema}
                  values={values}

                  onFormInit={(form) => {
                      form.watch((values) => {
                          onValueChange?.(values)

                      })
                  }} onSubmit={async e => {
            if (await onSubmit(e) === false) {
                return
            }

            nextStep()
        }}

        >

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions