I’m trying to fetch the IDs of categories from the category table and display them within this Form element. I need to select the ID from here and add the product accordingly. But I’m getting an error.
value={product.category || ‘default’}
it is giving an error here.
<FormField
control={form.control}
name="category"
render={({ field }) => (
<FormItem>
<FormControl>
<Select>
<SelectTrigger className="w-full">
<SelectValue placeholder="Kategoriler"/>
</SelectTrigger>
<SelectContent>
{
products.map((product)=>(
<SelectItem value={product.category || 'default'} {...field}>{product.category}</SelectItem>
))
}
</SelectContent>
</Select>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
New contributor
Ece is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.