primary-violetP
Refine3y ago
27 replies
primary-violet

Edit button not working in the useModalForm

Hi all,
I'm using a useModalForm hook to create a edit form. My approach is working for create action but not working for the edit action.
const {
        modalProps: createPrescriptionModalProps,
        show: showCreatePrescriptionModal,
        formProps: createPrescriptionFormProps,
        form: createPrescriptionForm,
    } = useModalForm<IPrescription>({
        action: "create",
        resource: "prescriptions",
        warnWhenUnsavedChanges: true,
        redirect: false,
    });

    const {
        modalProps: editPrescriptionModalProps,
        show: showEditPrescriptionModal,
        formProps: editPrescriptionFormProps,
        form: editPrescriptionForm,
    } = useModalForm<IPrescription>({
        action: "edit",
        // id: prescFound?.id,
        resource: "prescriptions",
        warnWhenUnsavedChanges: true,
        redirect: false,
    });


creteprescriptionForm and editPrescriptionForm are mostly same. Why the form is not opening when action set to edit?
Was this page helpful?