-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
form handle onsubmit not working #456
Comments
The In your schema, you've set a duration field but you don't have an actual field for it. So on submit, this is resulting into a required field/value missing. If you log What you can do here is:
|
Submit Button doesn't trigger🙏 Please help @shadcn 🙏 <Dialog open={open} onOpenChange={setOpen}>
<DialogTrigger asChild>
<Button variant="secondary">Add Contact</Button>
</DialogTrigger>
<DialogContent className="sm:max-w-[425px]">
<DialogHeader>
<DialogTitle>Add Contact</DialogTitle>
</DialogHeader>
<Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-8">
<FormField
control={form.control}
name="email"
render={({ field }) => (
<FormItem>
<FormLabel>Email</FormLabel>
<FormControl>
<Input placeholder="somename@gmail.com" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="phone"
render={({ field }) => (
<FormItem>
<FormLabel>Phone</FormLabel>
<FormControl>
<Input placeholder="eg: 06 28 29 59 30" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="name"
render={({ field }) => (
<FormItem>
<FormLabel>Name</FormLabel>
<FormControl>
<Input {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="relationship"
render={({ field }) => (
<FormItem>
<FormLabel>Relationship</FormLabel>
<Select
onValueChange={field.onChange}
defaultValue={field.value}
>
<FormControl>
<SelectTrigger>
<SelectValue placeholder="Select relationship" />
</SelectTrigger>
</FormControl>
<SelectContent>
<SelectItem value="mother">Mother</SelectItem>
<SelectItem value="father">Father</SelectItem>
<SelectItem value="brother">Brother</SelectItem>
<SelectItem value="sister">Sister</SelectItem>
<SelectItem value="uncle">Uncle</SelectItem>
<SelectItem value="aunt">Aunt</SelectItem>
</SelectContent>
</Select>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="avatar"
render={({ field }) => (
<FormItem>
<FormLabel>Avatar</FormLabel>
<FormControl>
<>
<Input
type="file"
accept="image/png, image/jpeg"
name="avatar"
onChange={(e) => {
if (e.target.files) {
field.onChange(e.target.files[0]);
}
}}
/>
<ProgressBar
progress={progress}
setProgress={setProgress}
/>
</>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<Button type="submit">Submit</Button>
</form>
</Form>
</DialogContent>
</Dialog> |
Hello everyone : ), Could anyone solve this problem? |
@salahbm , were you able to fix this? I'm experiencing the same issue (click on the submit button and nothing happens). UPDATE: |
@shadcn Yes, it was error related to |
Click the button but does not work onSubmit.. don't happen anything and zod validation does not work. Why ?? Please help me ! const formSchema = z.object({ export const action = async({ request }: ActionFunctionArgs) => {
} export default function Register() {
}` |
Hey everyone, Ik the thread is closed but leaving it here so it can help someone: |
Had same issue - u have to render FormField's for all defined fields in schema, pin it |
This is worked for me, thanks xD |
the onSubmit function has log statement but it's not logging anything when submit button is clicked.
The text was updated successfully, but these errors were encountered: