Form Utilities Library

This library contains form helpers mostly required by old modules (JS Engine v1.0).

Source:

Methods

(static) addHiddenByUrl($target, replace)

Adds a hidden field to the provided target.

Parameters:
Name Type Description
$target object

Target element to prepend the hidden field to.

replace boolean

Should the target element be replaced?

Source:

(static) createOptions($destination, dataset, addEmpty, order)

Create Options

Function to add options to a select field. The full dataset for each option is added at the option element.

Parameters:
Name Type Description
$destination object

jQuery-object of the select field.

dataset json

Array that contains several objects with at least a "name" and a "value" field.

addEmpty bool

If true, an empty select option will be generated (value = -1).

order bool

Orders the dataset by name if true.

Source:

(static) getData($form, ignoreSelector) → {object}

Returns the data from the form fields in a jQuery advantageous JSON format

Parameters:
Name Type Description
$form object

Target form selector object to be searched.

ignoreSelector string

Selector string to be ignored.

Source:
Returns:

Returns the data from the form elements.

Type
object

(static) getFieldType($element) → {string}

Returns the form field type.

Parameters:
Name Type Description
$element object

Element selector to be checked.

Source:
Returns:

Returns the field type name of the element.

Type
string

(static) prefillForm($form, options, trigger)

Pre-fills a form by the given key value pairs in "options".

Parameters:
Name Type Description
$form object

Element in which the form fields are searched.

options object

A JSON with key-value pairs for the form fields.

trigger boolean

A "change"-event gets triggered on the modified form field if true.

Source:

(static) reset($target)

Resets the the provided target form.

This method will clear all textfields. All radio buttons and checkboxes will be unchecked, only the first checkbox and radio button will get checked.

Parameters:
Name Type Description
$target object

Form to reset.

Source: