Keshav Khetan
Keshav Khetan

Reputation: 37

React hook form in react native, dynamic form

enter image description here

I need to build a form using react hook form where user can add multiple dates and a particular dates can have any number of events

My form code is


  const { control, setValue, getValues } = useForm<any>({
    defaultValues: {
      date: [],
      selectedDate: null,
      selectedEvent: null,
      eventName: '',
      bookingPerson: '',
      timeIn: '',
      noOfPeople: null,
      fPreferences: [],
      beverages: [],
    },
  });

I have made controlled input components and all other components like this using Controller API of react hook form.

<InputField
control={control}
formKey={`eventName`}
label="Event Name"
placeholder="Enter Event Name"
/>

How can i achieve this where user can add more dates and events in the form.

Upvotes: 0

Views: 29

Answers (0)

Related Questions