Options
All
  • Public
  • Public/Protected
  • All
Menu

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=false]

Include disabled fields?

param [options.readonly=false]

Include readonly fields?

Hierarchy

  • FormData
    • FormDataExtended

Index

Constructors

  • new FormDataExtended(form: any, __namedParameters?: { dtypes: {}; editors: {}; disabled: boolean; readonly: boolean }): FormDataExtended
  • 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: Object

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

      Methods

      • process(form: HTMLFormElement, options: any): void
      • 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

      • set(name: string, value: any): 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.

        inheritdoc

        Parameters

        • name: string

          The field name

        • value: any

          The raw extracted value from the field

        Returns void

      • append(name: string, value: any): void
      • Append values to the form data, adding them to an array.

        inheritdoc

        Parameters

        • name: string

          The field name to append to the form

        • value: any

          The value to append to the form data

        Returns void

      • #processFormFields(form: HTMLFormElement, options?: { disabled: boolean; readonly: boolean }): void
      • 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
          • readonly: boolean

        Returns void

      • #processEditableHTML(form: HTMLFormElement, options?: { disabled: boolean; readonly: boolean }): void
      • 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
          • readonly: boolean

        Returns void

      • #processEditors(): void
      • Process TinyMCE editor instances which are present in the form.

        Returns void

      • #getFieldValue(name: string, field: HTMLElement | RadioNodeList): any
      • 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

      • #castType(value: any, dataType: string): any
      • 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