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 [editors]

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

param [dtypes]

A mapping of data types for form fields

Hierarchy

  • FormData
    • FormDataExtended

Index

Constructors

  • new FormDataExtended(form: any, __namedParameters?: { editors: {}; dtypes: {} }): FormDataExtended
  • Parameters

    • form: any
    • __namedParameters: { editors: {}; dtypes: {} } = {}
      • editors: {}
        • dtypes: {}

        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): void
      • Process the HTML form element to populate the FormData instance.

        Parameters

        • form: HTMLFormElement

          The HTML form being processed

        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.

        Parameters

        • name: string

          The field name

        • value: any

          The raw extracted value from the field

        Returns void

      • #processFormFields(form: HTMLFormElement): void
      • Process all standard HTML form field elements from the form.

        Parameters

        • form: HTMLFormElement

          The form being processed

        Returns void

      • #processEditableHTML(form: HTMLFormElement): void
      • Process editable HTML elements (ones with a [data-edit] attribute).

        Parameters

        • form: HTMLFormElement

          The form being processed

        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