FormApplication

FormApplication

An abstract pattern for defining an Application responsible for updating some object using an HTML form

A few critical assumptions:

  1. This application is used to only edit one object at a time
  2. The template used contains one (and only one) HTML
    as it's outer-most element
  3. This abstract layer has no knowledge of what is being updated, so the implementation must define _updateObject

Constructor

new FormApplication(object, optionsopt)

Source:
Parameters:
Name Type Attributes Description
object *

Some object or entity which is the target to be updated.

options Object <optional>

Additional options which modify the rendering of the sheet.

Members

(static) defaultOptions

Source:

Assign the default options which are supported by the entity edit sheet. In addition to the default options object supported by the parent Application class, the Form Application supports the following additional keys and values:

editors :Object

Source:

Keep track of any mce editors which may be active as part of this form The values of this Array are inner-objects with references to the MCE editor and other metadata

Type:
  • Object

filepickers :Array

Source:

Keep track of any FilePicker instances which are associated with this form The values of this Array are inner-objects with references to the FilePicker instances and other metadata

Type:

form :HTMLElement

Source:

A convenience reference to the form HTMLElement

Type:
  • HTMLElement

isEditable :boolean

Source:

Is the Form Application currently editable?

Type:
  • boolean

object :*

Source:

The object target which we are using this form to modify

Type:
  • *

Methods

(async) _render()

Source:

(async) _renderInner()

Source:

(async, abstract) _updateObject(event, formData) → {Promise}

Source:

This method is called upon form submission after form data is validated

Parameters:
Name Type Description
event Event

The initial triggering submission event

formData Object

The object of validated form data with which to update the object

Returns:

A Promise which resolves once the update operation has completed

Type
Promise

activateListeners(html)

Source:

Activate the default set of listeners for the Entity sheet These listeners handle basic stuff like form submission or updating images

Parameters:
Name Type Description
html JQuery

The rendered template ready to have listeners attached

(async) close() → {Promise}

Source:

Extend the logic applied when the application is closed to destroy any remaining MCE instances This function returns a Promise which resolves once the window closing animation concludes

Parameters:
Name Type Description
options.submit boolean

Explicitly specify whether or not to submit the form when closing. Default behavior uses the value of FormApplication.options.submitOnClose.

Returns:
Type
Promise

getData()

Source:

submit(updateData) → {FormApplication}

Source:

Submit the contents of a Form Application, processing its content as defined by the Application

Parameters:
Name Type Description
updateData Object | null

Additional data updates to submit in addition to those parsed from the form

Returns:

Return a self-reference for convenient method chaining

Type
FormApplication