Form

Form

The Form class encapsulates a hypermedia form that can be updated with values at runtime and then submitted. TODO: More details on field values, etc.

Constructor

new Form(data, context)

Forms should not be created on their own, they are normally accessed from a containing Resource.

Parameters:
Name Type Description
data Object

The form data, including field information

context Context

The context of the form.

Source:

Methods

clone() → {Form}

Clone the current Form so that fields can be updated and not impact/change the original form field values.

Source:
Returns:

the cloned form.

Type
Form

field(name) → {Object}

Lookup the field by the given name.

Parameters:
Name Type Description
name string

The name of the field to look up.

Source:
Returns:

Object containing the field values.

Type
Object

getRequestData() → (nullable) {Object.<string, *>}

Get the name/value data for all the fields of the form.

Source:
Returns:

The name/value data for the fields of the form.

Type
Object.<string, *>

submit(optionsopt) → {Resource}

Perform an HTTP request to submit the form. The request itself is created based on the URL, method, type, and field values.

Parameters:
Name Type Attributes Description
options Object <optional>

The options for the request.

Properties
Name Type Attributes Description
protocol Object <optional>

Options to pass to the underlying protocol, e.g. http/https.

Source:
Returns:

A resource that will eventually be resolved with response details.

Type
Resource