Form

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

Included in: dx.mobile.js, dx.web.js, dx.viz-web.js, dx.all.js
Module: ui/form
Export: default
Form interactive configuration
Copy Code
Copy to Codepen
$("#form").dxForm({
});

You can create the widget using one of the following approaches.

jQuery
JavaScript
HTML
var companyData = {
    id: 1,
    name: "Super Mart of the West",
    city: "Bentonville",
    state: "Arkansas",
    zip: 72716,
    phone: "(800) 555-2797",
    fax: "(800) 555-2171",
    website: "http://www.nowebsite.com"
};
$(function () {
    $("#form").dxForm({
        formData: companyData,
        items: [
            'name', {
                itemType: 'group',
                caption: 'Location',
                items: ['city', 'state', 'zip']
            }, {
                itemType: 'group',
                caption: 'Contacts',
                items: ['phone', 'fax', 'website']
            }
        ]
    });
});
<div id="form"></div>
Angular
HTML
TypeScript
<dx-form
    [formData]="companyData">
    <dxi-item datafield="name"></dxi-item>
    <dxi-item
        itemType="group"
        caption="Location">
        <dxi-item dataField="city"></dxi-item>
        <dxi-item dataField="state"></dxi-item>
        <dxi-item dataField="zip"></dxi-item>
    </dxi-item>
    <dxi-item
        itemType="group"
        caption="Contacts">
        <dxi-item dataField="phone"></dxi-item>
        <dxi-item dataField="fax"></dxi-item>
        <dxi-item dataField="website"></dxi-item>
    </dxi-item>
</dx-form>
export class AppComponent {
    companyData = {
        id: 1,
        name: "Super Mart of the West",
        city: "Bentonville",
        state: "Arkansas",
        zip: 72716,
        phone: "(800) 555-2797",
        fax: "(800) 555-2171",
        website: "http://www.nowebsite.com"
    };
}
AngularJS
HTML
JavaScript
<div ng-controller="DemoController">
    <div dx-form="{
        formData: companyData,
        items: [
            'name', {
                itemType: 'group',
                caption: 'Location',
                items: ['city', 'state', 'zip']
            }, {
                itemType: 'group',
                caption: 'Contacts',
                items: ['phone', 'fax', 'website']
            }
        ]
    }"></div>
</div>
angular.module('DemoApp', ['dx'])
    .controller("DemoController", function ($scope) {
        $scope.companyData = {
            id: 1,
            name: "Super Mart of the West",
            city: "Bentonville",
            state: "Arkansas",
            zip: 72716,
            phone: "(800) 555-2797",
            fax: "(800) 555-2171",
            website: "http://www.nowebsite.com"
        };
    });
Knockout
HTML
JavaScript
<div data-bind="dxForm: {
    formData: companyData,
    items: [
        'name', {
            itemType: 'group',
            caption: 'Location',
            items: ['city', 'state', 'zip']
        }, {
            itemType: 'group',
            caption: 'Contacts',
            items: ['phone', 'fax', 'website']
        }
    ]
}"></div>
var viewModel = {
    companyData: {
        id: 1,
        name: "Super Mart of the West",
        city: "Bentonville",
        state: "Arkansas",
        zip: 72716,
        phone: "(800) 555-2797",
        fax: "(800) 555-2171",
        website: "http://www.nowebsite.com"
    }
};
ko.applyBindings(viewModel);
ASP.NET MVC Controls
Razor C#
Razor VB
@(Html.DevExtreme().Form()
    .FormData(new {
        id = 1,
        name = "Super Mart of the West",
        city = "Bentonville",
        state = "Arkansas",
        zip = 727161232,
        phone = "(800) 555-2797",
        fax = "(800) 555-2171",
        website = "http://www.nowebsite.com"
    })
    .Items(formItems => {
        formItems.AddSimple().DataField("name");
        formItems.AddGroup().Caption("Location").Items(locationItems => {
            locationItems.AddSimple().DataField("city");
            locationItems.AddSimple().DataField("state");
            locationItems.AddSimple().DataField("zip");
        });
        formItems.AddGroup().Caption("Contacts").Items(contactsItems => {
            contactsItems.AddSimple().DataField("phone");
            contactsItems.AddSimple().DataField("fax");
            contactsItems.AddSimple().DataField("website");
        });
    })
)
@(Html.DevExtreme().Form() _
    .FormData(New With {
        .id = 1,
        .name = "Super Mart of the West",
        .city = "Bentonville",
        .state = "Arkansas",
        .zip = 727161232,
        .phone = "(800) 555-2797",
        .fax = "(800) 555-2171",
        .website = "http://www.nowebsite.com"
    }) _
    .Items(Sub(formItems)
        formItems.AddSimple().DataField("name")
        formItems.AddGroup().Caption("Location").Items(Sub(locationItems)
            locationItems.AddSimple().DataField("city")
            locationItems.AddSimple().DataField("state")
            locationItems.AddSimple().DataField("zip")
        End Sub)
        formItems.AddGroup().Caption("Contacts").Items(Sub(contactsItems)
            contactsItems.AddSimple().DataField("phone")
            contactsItems.AddSimple().DataField("fax")
            contactsItems.AddSimple().DataField("website")
        End Sub)
    End Sub)
)  

Note that DevExtreme widgets require you to link the jQuery library to your application. If you use the Knockout or AngularJS approach, the Knockout or AngularJS library is also required. For detailed information on linking these libraries to your project, refer to the topics in the Installation section.

See Also
Show Example:
AngularJS
Knockout
jQuery

Configuration

An object defining configuration options for the Form widget.

Methods

This section describes members used to manipulate a widget.

Events

This section describes events fired by this widget.

See Also

Item Types

This section describes item types available in the Form widget.