Axinom Mosaic Libraries
    Preparing search index...

    Function ModalForm

    • This component is the basic building block for forms shown inside a modal.

      Its header actions are bound to the hosting modal instead of the router: 'Cancel' discards the changes and closes the modal, 'Save' calls saveData and closes the modal once the data was saved. A failed save keeps the modal open and shows the error.

      Use it with the useModal hook, or with useModalForm, which combines both.

      Type Parameters

      • TValues extends Data
      • TSubmitResponse = unknown

      Parameters

      Returns Element

      const { ModalWrapper, openModal } = useModal(({ closeModal }) => (
      <ModalForm<Genre>
      title="Edit Genre"
      closeModal={closeModal}
      initialData={{ loading, data }}
      saveData={saveData}
      >
      <Field name="title" label="Title" as={SingleLineTextField} />
      </ModalForm>
      ));