shadcn Form

Hello im having two forms made with shadcn components and react-hook-from Controller for validation

The idea is when u fill the first form and submit it. The second form takes the first one place.

I added a cancel button to take the user back to the the first one . I want it with all the fields filled up with the previous data but idk how to do it through the controller.

That's a code snippet.

<FormField
                control={form.control}
                name="Nom"
                render={({ field }) => (
                  <FormItem>
                    <FormControl>
                      <div className="flex flex-col space-y-1.5">
                        <Label
                          htmlFor="Nom"
                          className="text-lg flex justify-between"
                        >
                          Nom
                          <FormMessage />
                        </Label>
                        <Input
                          {...field}
                          id="Nom"
                          placeholder="John"
                          className={` ${
                            form.formState.errors.Nom &&
                            "border-err placeholder:text-destructives"
                          } text-md py-5 placeholder:opacity-40 rounded-sm border-[3px]  `}
                        />
                      </div>
                    </FormControl>
                  </FormItem>
                )}
              />
Was this page helpful?