React Form Props

An object defining configuration options for the Form widget.

See Also

accessKey

Specifies the shortcut key that sets focus on the widget.

Type:

String

Default Value: null

The value of this option will be passed to the accesskey attribute of the HTML element that underlies the widget.

activeStateEnabled

Specifies whether or not the widget changes its state when interacting with a user.

Type:

Boolean

Default Value: false

This option is used when the widget is displayed on a platform whose guidelines include the active state change for widgets.

alignItemLabels

Specifies whether or not all root item labels are aligned.

Type:

Boolean

Default Value: true

alignItemLabelsInAllGroups

Specifies whether or not item labels in all groups are aligned.

Type:

Boolean

Default Value: true

NOTE
This option applies only to those simple items that are nested within a group item. Thus, we recommend that you do not leave any simple items ungrouped if you need a consistent alignment throughout the Form.

colCount

The count of columns in the form layout.

Type:

Number

|

String

Default Value: 1
Accepted Values: 'auto'

NOTE

For extra small screens, this option always equals 1 to make the widget adaptive. To override this logic, specify the colCountByScreen option.

jQuery
JavaScript
$(function() {
    $("#formContainer").dxForm({
        // ...
        colCountByScreen: {
            xs: 2
        }
    });
});
Angular
HTML
TypeScript
<dx-form ... >
    <dxo-col-count-by-screen [xs]="2"></dxo-col-count-by-screen>
</dx-form>
import { DxFormModule } from "devextreme-angular";
// ...
export class AppComponent {
    // ...
}
@NgModule({
    imports: [
        // ...
        DxFormModule
    ],
    // ...
})

Use the Mode enum to specify this option when the widget is used as an ASP.NET MVC 5 Control or a DevExtreme-Based ASP.NET Core Control. This enum accepts the following values: Auto.

See Also

colCountByScreen

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

Type:

Object

Default Value: undefined

customizeItem

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

Type:

Function

Function parameters:

If you did not define form items using the items option, the Form widget creates them automatically according to the structure of an object passed to the formData option. The customizeItem option enables you to modify options of each generated item before this item is rendered. Each generated item passed to this function as an argument has a Simple Item structure.

If the items option contains definition for form items, you usually do not need to pass a function to the customizeItem option because you can customize items before passing them to the items option. However, if you assign a function to this option, it will be called for each item. In this case, an item can have structure corresponding to any of the following item types.

  • Simple
    A standard item consisting of a label and an editor widget used to specify a value of the associated data field.

  • Group
    An item representing a container of other form items.

  • Tabbed
    An item representing a tabbed container of other form items.

  • Empty
    An empty item used to add a space between neighboring form items.

See Also

disabled

Specifies whether the widget responds to user interaction.

Type:

Boolean

Default Value: false

elementAttr

Specifies the attributes to be attached to the widget's root element.

Type:

Object

Default Value: {}

jQuery
$(function(){
    $("#formContainer").dxForm({
        // ...
        elementAttr: {
            id: "elementId",
            class: "class-name"
        }
    });
});
Angular
HTML
TypeScript
<dx-form ...
    [elementAttr]="{ id: 'elementId', class: 'class-name' }">
</dx-form>
import { DxFormModule } from "devextreme-angular";
// ...
export class AppComponent {
    // ...
}
@NgModule({
    imports: [
        // ...
        DxFormModule
    ],
    // ...
})
ASP.NET MVC Controls
Razor C#
Razor VB
@(Html.DevExtreme().Form()
    .ElementAttr("class", "class-name")
    // ===== or =====
    .ElementAttr(new {
        @id = "elementId",
        @class = "class-name"
    })
    // ===== or =====
    .ElementAttr(new Dictionary<string, object>() {
        { "id", "elementId" },
        { "class", "class-name" }
    })

)
@(Html.DevExtreme().Form() _
    .ElementAttr("class", "class-name")
    ' ===== or =====
    .ElementAttr(New With {
        .id = "elementId",
        .class = "class-name"
    })
    ' ===== or =====
    .ElementAttr(New Dictionary(Of String, Object) From {
        { "id", "elementId" },
        { "class", "class-name" }
    })
)

focusStateEnabled

Specifies whether the widget can be focused using keyboard navigation.

Type:

Boolean

Default Value: false

formData

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

Type:

Object

Default Value: {}
Raised Events: onFieldDataChanged

height

Specifies the widget's height.

Type:

Number

|

String

|

Function

Return Value:

Number

|

String

The widget's height.

Default Value: undefined

This option accepts a value of one of the following types:

  • Number
    The height in pixels.

  • String
    A CSS-accepted measurement of height. For example, "55px", "80%", "inherit".

  • Function
    A function returning either of the above. For example:

    JavaScript
    height: function() {
        return window.innerHeight / 1.5;
    }

hint

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

Type:

String

Default Value: undefined

hoverStateEnabled

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

Type:

Boolean

Default Value: false

items

Holds an array of form items.

Simple Items Demo Grouped and Tabbed Items Demo Button Item Demo

When using the widget as an ASP.NET MVC 5 Control or a DevExtreme-Based ASP.NET Core Control, declare the items as follows:

Razor C#
Razor VB
@(Html.DevExtreme().Form()
    .FormData(Model.Data)
    .Items(rootItems => {
        rootItems.AddSimple().DataField("EmployeeID"); // Adds a simple item
        rootItems.AddEmpty(); // Adds an empty item
        rootItems.AddGroup().Caption("General Info") // Adds a group item
            .Items(groupItems => {
                groupItems.AddSimple().DataField("FirstName");
                // ...
            });
        rootItems.AddTabbed() // Adds a tabbed item
            .Tabs(tabs => {
                tabs.Add().Title("Address")
                    .Items(addressItems => {
                        addressItems.AddSimple().DataField("Country");
                        // ...
                    });
                tabs.Add().Title("Phone")
                    // ...
            });
        rootItems.AddButton() // Adds a button item
            .ButtonOptions(b => b.Text("Register")
                .Type(ButtonType.Success)
                .UseSubmitBehavior(true)
            );
    })
)
@(Html.DevExtreme().Form() _
    .FormData(Model.Data) _
    .Items(Sub(rootItems)
        rootItems.AddSimple().DataField("EmployeeID") ' Adds a simple item
        rootItems.AddEmpty() ' Adds an empty item
        ' Adds a group item
        rootItems.AddGroup().Caption("General Info") _
            .Items(Sub(groupItems)
                groupItems.AddSimple().DataField("FirstName")
                ' ...
            End Sub)
        ' Adds a tabbed item
        rootItems.AddTabbed() _
            .Tabs(Sub(tabs)
                tabs.Add().Title("Address") _
                    .Items(Sub(addressItems)
                        addressItems.AddSimple().DataField("Country")
                        ' ...
                    End Sub)
                tabs.Add().Title("Phone")
                    ' ...
            End Sub)
        ' Adds a button item
        rootItems.AddButton() _
            .ButtonOptions(Sub(b)
                b.Text("Register") _
                 .Type(ButtonType.Success) _
                 .UseSubmitBehavior(True)
            End Sub)
    End Sub)
)

labelLocation

Specifies the location of a label against the editor.

Type:

String

Default Value: 'left', 'top' (Material)
Accepted Values: 'left' | 'right' | 'top'

Use the FormLabelLocation enum to specify this option when the widget is used as an ASP.NET MVC 5 Control or a DevExtreme-Based ASP.NET Core Control. This enum accepts the following values: Left, Right, and Top.

See Also

minColWidth

The minimum column width used for calculating column count in the form layout.

Type:

Number

Default Value: 200

This option makes sense only if the colCount option is set to "auto".

NOTE
The actual column width equals the widget width divided by the column count.

onContentReady

A function that is executed when the widget's content is ready and each time the content is changed.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
component

Form

The widget's instance.

element

HTMLElement | jQuery

The widget's container. It is an HTML Element or a jQuery Element when you use jQuery.

model

Object

The model data. Available only when using Knockout.

Default Value: null

onDisposing

A function that is executed before the widget is disposed of.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
component

Form

The widget's instance.

element

HTMLElement | jQuery

The widget's container. It is an HTML Element or a jQuery Element when you use jQuery.

model

Object

The model data. Available only if you use Knockout.

Default Value: null

onEditorEnterKey

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

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
component

Form

The widget's instance.

dataField

String

The path to the formData object field associated with the current editor.

element

HTMLElement | jQuery

The widget's container. It is an HTML Element or a jQuery Element when you use jQuery.

model

Object

The model data. Available only if Knockout is used.

Default Value: null

IMPORTANT
This function is executed only if the editor raises the enterKey event. See the Events section in the editor's API reference for the list of events the editor can raise. If the enterKey event is absent from the list, but you need to handle the Enter key press, use another editor.

onFieldDataChanged

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

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
component

Form

The widget's instance.

dataField

String

The path to the formData object field whose value has been changed.

element

HTMLElement | jQuery

The widget's container. It is an HTML Element or a jQuery Element when you use jQuery.

model

Object

The model data. Available only if Knockout is used.

value

Object

The field's new value.

Default Value: null

onInitialized

A function used in JavaScript frameworks to save the widget instance.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
component

Form

The widget's instance.

element

HTMLElement | jQuery

The widget's container. It is an HTML Element or a jQuery Element when you use jQuery.

Default Value: null

See Also

onOptionChanged

A function that is executed after a widget option is changed.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
model

Object

The model data. Available only if you use Knockout.

fullName

String

The path to the modified option that includes all parent options.

element

HTMLElement | jQuery

The widget's container. It is an HTML Element or a jQuery Element when you use jQuery.

component

Form

The widget's instance.

name

String

The modified option if it belongs to the first level. Otherwise, the first-level option it is nested into.

value any

The modified option's new value.

Default Value: null

optionalMark

The text displayed for optional fields.

Type:

String

Default Value: 'optional'

See Also

readOnly

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

Type:

Boolean

Default Value: false

requiredMark

The text displayed for required fields.

Type:

String

Default Value: '*'

See Also

requiredMessage

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

Type:

String

Default Value: '{0} is required'

rtlEnabled

Switches the widget to a right-to-left representation.

Type:

Boolean

Default Value: false

When this option is set to true, the widget text flows from right to left, and the layout of elements is reversed. To switch the entire application/site to the right-to-left representation, assign true to the rtlEnabled field of the object passed to the DevExpress.config(config) method.

JavaScript
DevExpress.config({
    rtlEnabled: true
});
See Also

screenByWidth

Specifies a function that categorizes screens by their width.

Type:

Function

Default Value: null

The widget uses the following size qualifiers to categorize screens by width:

Size Qualifier Description
xs Stands for "extra small". Screens with width less than 768 pixels.
sm Stands for "small". Screens with width between 768 and 992 pixels.
md Stands for "medium". Screens with width between 992 and 1200 pixels.
lg Stands for "large". Screens with width more than 1200 pixels.

Implement the screenByWidth function to change the relation between a size qualifier and screen width. This function accepts the screen width and should return a size qualifier. The following code shows the function's default implementation that you can customize:

jQuery
JavaScript
$(function() {
    $("#formContainer").dxForm({
        // ...
        screenByWidth: function(width) {
            if (width < 768) return "xs";
            if (width < 992) return "sm";
            if (width < 1200) return "md";
            return "lg";
        }
    });
});
Angular
TypeScript
HTML
import { DxFormModule } from "devextreme-angular";
// ...
export class AppComponent {
    // ...
    getSizeQualifier(width) {
        if (width < 768)  return "xs";
        if (width < 992)  return "sm";
        if (width < 1200) return "md";
        return "lg";
    }
}
@NgModule({
    imports: [
        // ...
        DxFormModule
    ],
    // ...
})
<dx-form ...
    [screenByWidth]="getSizeQualifier">
</dx-form>

View Demo

scrollingEnabled

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

Type:

Boolean

Default Value: false

showColonAfterLabel

Specifies whether or not a colon is displayed at the end of form labels.

Type:

Boolean

Default Value: true, false (Material)

showOptionalMark

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

Type:

Boolean

Default Value: false

See Also

showRequiredMark

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

Type:

Boolean

Default Value: true

See Also

showValidationSummary

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

Type:

Boolean

Default Value: false

tabIndex

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

Type:

Number

Default Value: 0

The value of this option will be passed to the tabindex attribute of the HTML element that underlies the widget.

validationGroup

Gives a name to the internal validation group.

Type:

String

Default Value: undefined

In some cases, the Form editors should be validated by the Button widget. By default, these editors are collected in an unnamed validation group, what makes it impossible for the Button to validate them. In this case, give this validation group a name using the validationGroup option of the Form widget. Also, pass the same name to the validationGroup option of the Button widget.

$(function () {
    $("#formContainer").dxForm({
        // ...
        validationGroup: "groupName"
    });

    $("#buttonContainer").dxButton({
        // ...
        validationGroup: "groupName",
        onClick: function (e) {
            e.validationGroup.validate();
        }
    });
})

View Demo

visible

Specifies whether the widget is visible.

Type:

Boolean

Default Value: true

width

Specifies the widget's width.

Type:

Number

|

String

|

Function

Return Value:

Number

|

String

The widget's width.

Default Value: undefined

This option accepts a value of one of the following types:

  • Number
    The width in pixels.

  • String
    A CSS-accepted measurement of width. For example, "55px", "80%", "auto", "inherit".

  • Function
    A function returning either of the above. For example:

    JavaScript
    width: function() {
        return window.innerWidth / 1.5;
    }
NOTE

Even if the width of the widget is specified, the count of columns may depend on the screen width. For example, if the screen width is not enough to display the whole form's container, the count of columns depends on the screen width, not the container. To always use a fixed count of columns regardless of the screen width, pass an empty function to the screenByWidth option.

JavaScript
screenByWidth: function() { }