Interface FormContext

Hierarchy

  • FormContext

Properties

actions: {
    cancel?: (() => void);
}

This property provides a way to cancel the form and call onCancel.

Type declaration

  • Optional cancel?: (() => void)
      • (): void
      • Returns void

error: null | string | Error

Global error associated with the form.

See

FormError

fields: {
    [key: string]: {
        error?: string | null;
        required?: boolean;
        schema?: SchemaValidator;
        validate?: ((value: string) => void);
    };
}

Field data for each field.

Type declaration

  • [key: string]: {
        error?: string | null;
        required?: boolean;
        schema?: SchemaValidator;
        validate?: ((value: string) => void);
    }
    • Optional error?: string | null
    • Optional required?: boolean
    • Optional schema?: SchemaValidator
    • Optional validate?: ((value: string) => void)
        • (value: string): void
        • Parameters

          • value: string

          Returns void

formik: FormikProps<Record<string, any>>

The internal Formik instance

handleChange: ((event: ChangeEvent<HTMLInputElement>, id: string) => void)

Type declaration

    • (event: ChangeEvent<HTMLInputElement>, id: string): void
    • Handle the changing of a field's value

      Parameters

      • event: ChangeEvent<HTMLInputElement>
      • id: string

        The field's ID

      Returns void

i18n: {
    cancel?: string;
    required?: string;
    submit?: string;
}

The custom button labels provided in FormProps

Type declaration

  • Optional cancel?: string
  • Optional required?: string
  • Optional submit?: string
id: string

The ID of this form

loading: boolean

Whether the submit action for this form is still processing.

options: {
    initialFocus?: string;
    showRequiredSign?: boolean;
}

Type declaration

  • Optional initialFocus?: string
  • Optional showRequiredSign?: boolean
setError: ((error: null | string) => void)

Type declaration

    • (error: null | string): void
    • Set the global error for the form.

      Parameters

      • error: null | string

      Returns void

setField: ((id: string, value: string, options?: {
    error?: null | string;
    required?: boolean;
    schema?: Partial<LengthValidator & StringValidator>;
    validate?: ((value: string) => void);
}) => void)

Type declaration

    • (id: string, value: string, options?: {
          error?: null | string;
          required?: boolean;
          schema?: Partial<LengthValidator & StringValidator>;
          validate?: ((value: string) => void);
      }): void
    • Set the field data for a field. Unrecommended that you tamper with this.

      Parameters

      • id: string
      • value: string
      • Optional options: {
            error?: null | string;
            required?: boolean;
            schema?: Partial<LengthValidator & StringValidator>;
            validate?: ((value: string) => void);
        }
        • Optional error?: null | string
        • Optional required?: boolean
        • Optional schema?: Partial<LengthValidator & StringValidator>
        • Optional validate?: ((value: string) => void)
            • (value: string): void
            • Parameters

              • value: string

              Returns void

      Returns void

setFieldError: ((id: string, error: null | string) => void)

Type declaration

    • (id: string, error: null | string): void
    • Set the error for a field.

      Parameters

      • id: string
      • error: null | string

      Returns void

Accessors

  • get values(): Record<string, string>
  • The current values associated with a field.

    Returns Record<string, string>

Generated using TypeDoc