Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <FormField
- control={form.control}
- name="items"
- render={() => (
- <FormItem>
- <div className="mb-4">
- <FormLabel className="text-base">
- TCET Assistance
- </FormLabel>
- </div>
- {items.map((item) => (
- <FormField
- key={item.id}
- control={form.control}
- name="items"
- render={({ field }) => {
- return (
- <FormItem
- key={item.id}
- className="flex flex-row items-start space-x-3 space-y-0"
- >
- <FormControl>
- <Checkbox
- checked={field.value?.includes(item.id)}
- onCheckedChange={(checked) => {
- // Ensure field.value is an array before using methods like includes() and filter()
- if (Array.isArray(field.value)) {
- field.onChange(
- checked
- ? [...field.value, item.id]
- : field.value.filter(
- (value) => value !== item.id
- )
- );
- } else {
- // If field.value is not an array, handle the case accordingly
- // For example, set it to an empty array if appropriate
- field.onChange(checked ? [item.id] : []);
- }
- }}
- />
- </FormControl>
- <FormLabel className="text-sm font-normal">
- {item.label}
- </FormLabel>
- </FormItem>
- );
- }}
- />
- ))}
- <FormMessage />
- </FormItem>
- )}
- />
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement