DevExtreme v23.1 is now available.

Explore our newest features/capabilities and share your thoughts with us.

Your search did not match any results.
Form

Overview

The Form component builds a data entry UI for an object assigned to the formData property. The component displays and aligns label-editor pairs for each field in the bound object.

You can use the editors on the right to modify the following properties:

  • labelMode: "outside" | "static" | "floating" | "hidden"
    Specifies label display mode.

  • labelLocation: "top" | "left" | "right"
    Specifies whether to place outer labels above, to the left, or to the right of corresponding editors. The latter location is not demonstrated in this example.

  • colCount
    Specifies the number of columns in the layout. To build an adaptive layout where the column count depends on the container width, set this property's value to "auto".

  • minColWidth
    Specifies the minimum column width. Use this property when the colCount property's value is "auto".

  • width
    Specifies the Form component's width.

  • readOnly
    Makes the Form editors read-only.

  • showColonAfterLabel
    Specifies whether the Form displays a colon after a label.

To get started with the DevExtreme Form component, refer to the following tutorial for step-by-step instructions: Getting Started with Form.

Backend API
Copy to CodePen
Apply
Reset
const DemoApp = angular.module('DemoApp', ['dx']); DemoApp.controller('DemoController', ($scope) => { $scope.showColon = true; $scope.data = companies[0]; $scope.readOnly = false; $scope.labelMode = 'floating'; $scope.labelLocation = 'left'; $scope.minColWidth = 300; $scope.colCount = 2; $scope.widthValue = undefined; $scope.getCompanySelectorLabelMode = () => { if ($scope.labelMode === 'outside') { return 'hidden'; } return $scope.labelMode; }; $scope.formOptions = { bindingOptions: { formData: 'data', readOnly: 'readOnly', showColonAfterLabel: 'showColon', labelMode: 'labelMode', labelLocation: 'labelLocation', minColWidth: 'minColWidth', colCount: 'colCount', width: 'widthValue', }, }; $scope.selectCompanyOptions = { displayExpr: 'Name', label: 'Select company', dataSource: companies, bindingOptions: { labelMode: 'getCompanySelectorLabelMode()', value: 'data', }, }; $scope.readOnlyOptions = { text: 'readOnly', bindingOptions: { value: 'readOnly', }, }; $scope.showColonOptions = { text: 'showColonAfterLabel', bindingOptions: { value: 'showColon', }, }; $scope.labelModeOptions = { items: ['outside', 'static', 'floating', 'hidden'], bindingOptions: { value: 'labelMode', }, }; $scope.labelLocationOptions = { items: ['left', 'top'], bindingOptions: { value: 'labelLocation', }, }; $scope.minColWidthOptions = { items: [150, 200, 300], bindingOptions: { value: 'minColWidth', }, }; $scope.colCountOptions = { items: ['auto', 1, 2, 3], bindingOptions: { value: 'colCount', }, }; $scope.widthOptions = { max: 550, bindingOptions: { value: 'widthValue', }, }; });
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>DevExtreme Demo</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script>window.jQuery || document.write(decodeURIComponent('%3Cscript src="js/jquery.min.js"%3E%3C/script%3E'))</script> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/23.1.5/css/dx.light.css" /> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js"></script> <script>window.angular || document.write(decodeURIComponent('%3Cscript src="js/angular.min.js"%3E%3C/script%3E'))</script> <script src="https://cdn3.devexpress.com/jslib/23.1.5/js/dx.all.js"></script> <script src="data.js"></script> <link rel="stylesheet" type="text/css" href="styles.css" /> <script src="index.js"></script> </head> <body class="dx-viewport"> <div class="demo-container" ng-app="DemoApp" ng-controller="DemoController"> <div id="form-demo"> <div class="widget-container"> <div ng-if="labelMode === 'outside'">Select company:</div> <div dx-select-box="selectCompanyOptions"></div> <div id="form" dx-form="formOptions"></div> </div> <div class="options"> <div class="caption">Options</div> <div class="option"> <span>Label mode:</span> <div dx-select-box="labelModeOptions"></div> </div> <div class="option"> <span>Label location:</span> <div dx-select-box="labelLocationOptions"></div> </div> <div class="option"> <span>Columns count:</span> <div dx-select-box="colCountOptions"></div> </div> <div class="option"> <span>Min column width:</span> <div dx-select-box="minColWidthOptions"></div> </div> <div class="option"> <span>Form width:</span> <div dx-number-box="widthOptions"></div> </div> <div class="option"> <div dx-check-box="readOnlyOptions"></div> </div> <div class="option"> <div dx-check-box="showColonOptions"></div> </div> </div> </div> </div> </body> </html>
.widget-container { margin-right: 320px; padding: 20px; max-width: 550px; min-width: 300px; } #form { margin-top: 25px; } .options { padding: 20px; position: absolute; bottom: 0; right: 0; width: 260px; top: 0; background-color: rgba(191, 191, 191, 0.15); } .caption { font-size: 18px; font-weight: 500; } .option { margin-top: 10px; }
const companies = [{ ID: 1, Name: 'Super Mart of the West', Address: '702 SW 8th Street', City: 'Bentonville', State: 'Arkansas', ZipCode: 72716, Phone: '(800) 555-2797', Fax: '(800) 555-2171', Website: '', Active: true, }, { ID: 2, Name: 'Electronics Depot', Address: '2455 Paces Ferry Road NW', City: 'Atlanta', State: 'Georgia', ZipCode: 30339, Phone: '(800) 595-3232', Fax: '(800) 595-3231', Website: '', Active: true, }, { ID: 3, Name: 'K&S Music', Address: '1000 Nicllet Mall', City: 'Minneapolis', State: 'Minnesota', ZipCode: 55403, Phone: '(612) 304-6073', Fax: '(612) 304-6074', Website: '', Active: true, }, { ID: 4, Name: "Tom's Club", Address: '999 Lake Drive', City: 'Issaquah', State: 'Washington', ZipCode: 98027, Phone: '(800) 955-2292', Fax: '(800) 955-2293', Website: '', Active: true, }];