An extension of the native FormData implementation.

This class functions the same way that the default FormData does, but it is more opinionated about how input fields of certain types should be evaluated and handled.

It also adds support for certain Foundry VTT specific concepts including: Support for defined data types and type conversion Support for TinyMCE editors Support for editable HTML elements

Param: form

The form being processed

Param: options

Options which configure form processing

Param: options.editors

A record of TinyMCE editor metadata objects, indexed by their update key

Param: options.dtypes

A mapping of data types for form fields

Param: options.disabled

Include disabled fields?

Param: options.readonly

Include readonly fields?

Hierarchy

  • FormData
    • FormDataExtended

Constructors

  • Parameters

    • form: any
    • __namedParameters: {
          dtypes: {};
          editors: {};
          disabled: boolean;
          readonly: boolean;
      } = {}
      • dtypes: {}
        • editors: {}
          • disabled: boolean
          • readonly: boolean

        Returns FormDataExtended

      Properties

      dtypes: {
          string: any;
      }

      A mapping of data types requested for each form field.

      Type declaration

      • string: any
      editors: {}

      A record of TinyMCE editors which are linked to this form.

      Type declaration

        Methods

        • Process the HTML form element to populate the FormData instance.

          Parameters

          • form: HTMLFormElement

            The HTML form being processed

          • options: any

            Options forwarded from the constructor

          Returns void

        • Assign a value to the FormData instance which always contains JSON strings. Also assign the cast value in its preferred data type to the parsed object representation of the form data.

          Parameters

          • name: string

            The field name

          • value: any

            The raw extracted value from the field

          Returns void

          Inherit Doc

        • Append values to the form data, adding them to an array.

          Parameters

          • name: string

            The field name to append to the form

          • value: any

            The value to append to the form data

          Returns void

          Inherit Doc

        • Private

          Process all standard HTML form field elements from the form.

          Parameters

          • form: HTMLFormElement

            The form being processed

          • options: {
                disabled: boolean;
                readonly: boolean;
            } = {}

            Options forwarded from the constructor

            • disabled: boolean

              Process disabled fields?

            • readonly: boolean

              Process readonly fields?

          Returns void

        • Private

          Process editable HTML elements (ones with a [data-edit] attribute).

          Parameters

          • form: HTMLFormElement

            The form being processed

          • options: {
                disabled: boolean;
                readonly: boolean;
            } = {}

            Options forwarded from the constructor

            • disabled: boolean

              Process disabled fields?

            • readonly: boolean

              Process readonly fields?

          Returns void

        • Private

          Process TinyMCE editor instances which are present in the form.

          Returns void

        • Private

          Obtain the parsed value of a field conditional on its element type and requested data type.

          Parameters

          • name: string

            The field name being processed

          • field: HTMLElement | RadioNodeList

            The HTML field or a RadioNodeList of multiple fields

          Returns any

          The processed field value

        • Private

          Cast a processed value to a desired data type.

          Parameters

          • value: any

            The raw field value

          • dataType: string

            The desired data type

          Returns any

          The resulting data type