Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface FormProps<TModel>

Type parameters

  • TModel = {[ key in string]: any }

Hierarchy

Index

Properties

Optional addFields

addFields: string[]

Optional cancelLabel

cancelLabel: string

Optional children

children: ReactNode

Optional contextName

contextName: string

Label so that graphql queries are contextualized

Optional currentUser

currentUser: VulcanUser

currentUser to check authorizations to update/create some fields

Optional disabled

disabled: boolean

Disable the form

Optional document

document: any

Passing directly a document (TODO: not yet tested in the new version)

Optional documentId

documentId: string

Optional fields

fields: keyof TModel[]

Optional id

id: string

Document id in update mode

Optional initCallback

initCallback: Function

Callback ran on first render

Optional itemProperties

itemProperties: Object

Optional layout

layout: "horizontal" | "vertical"

model

model: VulcanModel<VulcanSchema<AnyObject>>

Optional mutationFragment

mutationFragment: string | DocumentNode

A GraphQL fragment used to specify the data to return once a mutation is complete.

If no fragment is passed, SmartForm will only return fields used in the form, but note that this might sometimes lead to discrepancies when compared with documents already loaded on the client.

An example would be a createdAt date added automatically on creation even though it’s not part of the actual form. If you’d like that field to be returned after the mutation, you can define a custom mutationFragment that includes it explicitly.

Can be either a string or a DocumentNode (using "gql" tag)

Optional mutationFragmentName

mutationFragmentName: string

Force a mutation fragment name

NOTE: needed only for string fragments If you use a DocumentNode (with "gql" tag), it will be computed automatically

deprecated

Prefer using DocumentNode fragment, using the gql tag

Optional prefilledProps

prefilledProps: TModel & Object

Optional queryFragment

queryFragment: string | DocumentNode

A GraphQL fragment used to specify the data to fetch to populate edit forms. If no fragment is passed, SmartForm will do its best to figure out what data to load based on the fields included in the form.

Can be either a string or a DocumentNode (using "gql" tag)

Optional queryFragmentName

queryFragmentName: string

Force a query fragment name

NOTE: needed only for string fragments If you use a DocumentNode (with "gql" tag), it will be computed automatically

deprecated

Prefer using DocumentNode fragment, using the gql tag

Optional removeFields

removeFields: string[]

Optional repeatErrors

repeatErrors: boolean

Optional revertCallback

revertCallback: Function

Optional revertLabel

revertLabel: string

Optional schema

schema: VulcanSchema<AnyObject>

Passing directly a raw schema (TODO: model is still mandatory atm)

Optional showDelete

showDelete: boolean

Optional showRemove

showRemove: boolean

Optional submitLabel

submitLabel: string

Optional successComponent

successComponent: any

Optional warnUnsavedChanges

warnUnsavedChanges: boolean

Will prevent leaving the page/unmounting the form on unsaved changes

Methods

Optional cancelCallback

  • cancelCallback(document: any): void
  • Parameters

    • document: any

    Returns void

changeCallback

  • changeCallback(currentDocument: any): void
  • Parameters

    • currentDocument: any

    Returns void

createDocument

  • The result is usually extracted from a graphql mutation But we have a simplified abstracted API, so we could also use the Form without graphql

    Type parameters

    • TModel = any

    Parameters

    Returns Promise<CreateDocumentResult<TModel>>

deleteDocument

  • Parameters

    Returns Promise<void>

Optional errorCallback

  • errorCallback(document: any, error: any, meta: { form: any }): void
  • Parameters

    • document: any
    • error: any
    • meta: { form: any }
      • form: any

    Returns void

Optional refetch

  • refetch(): void
  • Function that retriggers data fetching in edit mode Usually provided by the useSingle but could be any function

    Returns void

Optional removeSuccessCallback

  • removeSuccessCallback(document: any): void
  • Parameters

    • document: any

    Returns void

Optional submitCallback

  • submitCallback(data: any): any

Optional successCallback

  • successCallback(document: any, meta: { form: any }): void
  • Parameters

    • document: any
    • meta: { form: any }
      • form: any

    Returns void

updateDocument

  • Type parameters

    • TModel = any

    Parameters

    Returns Promise<UpdateDocumentResult<TModel>>

Generated using TypeDoc