diff --git a/src/components/purchase-orders/PurchaseOrderForm.tsx b/src/components/purchase-orders/PurchaseOrderForm.tsx index 4ea3dbe..d776957 100644 --- a/src/components/purchase-orders/PurchaseOrderForm.tsx +++ b/src/components/purchase-orders/PurchaseOrderForm.tsx @@ -126,14 +126,14 @@ export function PurchaseOrderForm({ setOpen, refreshData }: PurchaseOrderFormPro // Function to add a new item row const addItem = () => { - form.control.register("items", { shouldUnregister: true }) // Ensure registration - form.setValue("items", [...form.getValues("items"), { + const currentItems = form.getValues("items"); + form.setValue("items", [...currentItems, { stockItemId: "", itemName: "", quantity: 1, sku: "", costPrice: 0, - }]) + }]); } // Function to remove an item row