A newer version of this page is available. Switch to the current version.

JavaScript/jQuery Form API

The Form UI component represents fields of a data object as a collection of label-editor pairs. These pairs can be arranged in several groups, tabs and columns.

import Form from "devextreme/ui/form"

Options

An object defining configuration properties for the Form UI component.

Name Description
accessKey

Specifies the shortcut key that sets focus on the UI component.

activeStateEnabled

Specifies whether the UI component changes its visual state as a result of user interaction.

alignItemLabels

Specifies whether all item labels are aligned. Applies only to labels outside their editors (see labelMode).

alignItemLabelsInAllGroups

Specifies whether item labels in all groups are aligned. Applies only to labels outside their editors (see labelMode).

colCount

The count of columns in the form layout.

colCountByScreen

Specifies dependency between the screen factor and the count of columns in the form layout.

customizeItem

Specifies a function that customizes a form item after it has been created.

disabled

Specifies whether the UI component responds to user interaction.

elementAttr

Specifies the global attributes to be attached to the UI component's container element.

focusStateEnabled

Specifies whether the UI component can be focused using keyboard navigation.

formData

Provides the Form's data. Gets updated every time form fields change.

height

Specifies the UI component's height.

hint

Specifies text for a hint that appears when a user pauses on the UI component.

hoverStateEnabled

Specifies whether the UI component changes its state when a user pauses on it.

isDirty

Specifies whether current editor values differ from initial values.

items

Holds an array of form items.

labelLocation

Specifies the location of a label against the editor. Applies only to labels outside their editors (see labelMode).

labelMode

Specifies a display mode for item labels.

minColWidth

The minimum column width used for calculating column count in the form layout. Applies only if colCount property is "auto".

onContentReady

A function that is executed when the UI component is rendered and each time the component is repainted.

onDisposing

A function that is executed before the UI component is disposed of.

onEditorEnterKey

A function that is executed when the Enter key has been pressed while an editor is focused.

onFieldDataChanged

A function that is executed when the value of a formData object field is changed.

onInitialized

A function used in JavaScript frameworks to save the UI component instance.

onOptionChanged

A function that is executed after a UI component property is changed.

optionalMark

The text displayed for optional fields. Applies only if showOptionalMark is true.

readOnly

Specifies whether all editors on the form are read-only. Applies only to non-templated items.

requiredMark

The text displayed for required fields.

requiredMessage

Specifies the message that is shown for end-users if a required field value is not specified.

rtlEnabled

Switches the UI component to a right-to-left representation.

screenByWidth

Specifies a function that categorizes screens by their width.

scrollingEnabled

A Boolean value specifying whether to enable or disable form scrolling.

showColonAfterLabel

Specifies whether a colon is displayed at the end of form labels. Applies only to labels outside their editors (see labelMode).

showOptionalMark

Specifies whether or not the optional mark is displayed for optional fields.

showRequiredMark

Specifies whether or not the required mark is displayed for required fields.

showValidationSummary

Specifies whether or not the total validation summary is displayed on the form.

tabIndex

Specifies the number of the element when the Tab key is used for navigating.

validationGroup

Gives a name to the internal validation group.

visible

Specifies whether the UI component is visible.

width

Specifies the UI component's width.

Methods

This section describes members used to manipulate a UI component.

Name Description
beginUpdate()

Postpones rendering that can negatively affect performance until the endUpdate() method is called.

clear()

Resets editor values to their default values.

defaultOptions(rule)

Specifies the device-dependent default configuration properties for this component.

dispose()

Disposes of all the resources allocated to the Form instance.

element()

Gets the root UI component element.

endUpdate()

Refreshes the UI component after a call of the beginUpdate() method.

focus()

Sets focus on the UI component.

getButton(name)

Gets a button's instance.

getEditor(dataField)

Gets an editor instance. Takes effect only if the form item is visible.

getInstance(element)

Gets the instance of a UI component found using its DOM node.

instance()

Gets the UI component's instance. Use it to access other methods of the UI component.

itemOption(id)

Gets a form item's configuration.

itemOption(id, options)

Updates the values of several item properties.

itemOption(id, option, value)

Updates the value of a single item option.

off(eventName)

Detaches all event handlers from a single event.

off(eventName, eventHandler)

Detaches a particular event handler from a single event.

on(eventName, eventHandler)

Subscribes to an event.

on(events)

Subscribes to events.

option()

Gets all UI component properties.

option(optionName)

Gets the value of a single property.

option(optionName, optionValue)

Updates the value of a single property.

option(options)

Updates the values of several properties.

registerKeyHandler(key, handler)

Registers a handler to be executed when a user presses a specific key.

repaint()

Renders the component again without reloading data. Use the method to update the component's markup and appearance dynamically.

reset(editorsData)

Resets editor values. Every editor attempts to obtain its new value from the argument list. If an editor is not included in the list, that editor resets to its initial value.

resetOption(optionName)

Resets a property to its default value.

updateData(data)

Merges the passed data object with formData. Matching properties in formData are overwritten and new properties added.

updateData(dataField, value)

Updates a formData field and the corresponding editor.

updateDimensions()

Updates the dimensions of the UI component contents.

validate()

Validates the values of all editors on the form against the list of the validation rules specified for each form item.

See Also

Events

This section describes events fired by this UI component.

Name Description
contentReady

Raised when the UI component is rendered and each time the component is repainted.

disposing

Raised before the UI component is disposed of.

editorEnterKey

Raised when the Enter key has been pressed while an editor is focused.

fieldDataChanged

Raised when the value of a formData object field is changed.

initialized

Raised only once, after the UI component is initialized.

optionChanged

Raised after a UI component property is changed.

See Also

Item Types

This section describes item types available in the Form UI component.

Name Description
ButtonItem

Configures a button form item.

EmptyItem

This article describes configuration properties of an empty form item.

GroupItem

This article describes configuration properties of a group form item.

SimpleItem

This article describes configuration properties of a simple form item.

TabbedItem

This article describes configuration properties of a tabbed form item. You can specify its options in the tabPanelOptions object.

Types

Name Description
ContentReadyEvent

The type of the contentReady event handler's argument.

DisposingEvent

The type of the disposing event handler's argument.

EditorEnterKeyEvent

The type of the editorEnterKey event handler's argument.

FieldDataChangedEvent

The type of the fieldDataChanged event handler's argument.

FormItemComponent

Specifies which editor UI component is used to display and edit the form item value.

FormItemType

Specifies the item's type.

FormLabelMode

Specifies a display mode for item labels.

InitializedEvent

The type of the initialized event handler's argument.

LabelLocation

Specifies the location of a label against the editor.

OptionChangedEvent

The type of the optionChanged event handler's argument.