Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select is not working with controlled component; #130

Open
Vedant-LC opened this issue Nov 18, 2024 · 0 comments
Open

Select is not working with controlled component; #130

Vedant-LC opened this issue Nov 18, 2024 · 0 comments

Comments

@Vedant-LC
Copy link

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()
        }}

        >
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant