Open DavithCH opened 3 months ago
For handling null values Zod is used for this component, which gives error when no date is selected and submit button pressed. So i would recommend you to use Zod for handling null actions, and if you're getting null despite securing the default value, then problem might be in your code somewhere, where you're implementing default value logic.
Describe the bug
I am using Calender with react hook form and passing defautValue as null. After clicking submit it converted my value to a date 01 01 1970.
Affected component/components
Calender
How to reproduce
import { Popover, PopoverTrigger } from "@radix-ui/react-popover"; import { FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, } from "./ui/form";
import { cn } from "@/lib/utils"; import { Button } from "./ui/button"; import { format } from "date-fns"; import { fr } from "date-fns/locale"; import { CalendarIcon } from "lucide-react"; import { PopoverContent } from "./ui/popover"; import { Calendar } from "./CustomCalender"; import { Control, FieldValues } from "react-hook-form"; import { RequiredFormLabel } from "./RequiredFormLabel";
type Props< TFieldValues extends FieldValues = FieldValues, TContext = unknown
const DatePickerForm = ({ name, control, label, placeholder, className, required, disabled, }: Props) => { return ( <FormField control={control} name={name} render={({ field }) => { return ( <FormItem className={cn("min-w-[150px] w-full", className)}> {required ? (
); };
export default DatePickerForm;
Codesandbox/StackBlitz link
No response
Logs
No response
System Info
Before submitting