Form Groups fields into sections and checks required values.
kor/ui/FormSource
When to use Give related fields a section heading and validate before saving.
Examples
Validate a required field
View.xml Controller.js
Run Reset Copy Open in playground
<k:Stack gap ="12" >
<k:Form id ="form" >
<k:FormSection title ="Contact" >
<k:TextField label ="Name" required ="true" />
</k:FormSection >
</k:Form >
<k:Button kind ="primary" text ="Save contact" press =".onSave" />
</k:Stack > sap.ui.define(["sap/ui/core/mvc/Controller" , "kor/ui/Toast" ], (Controller, Toast) => Controller.extend("sample.ValidateForm" , {
onSave() {
if (this .byId("form" ).validate()) Toast.show("Form saved" );
}
}));
Edit dispatch details
View.xml Controller.js
Run Reset Copy Open in playground
<k:Stack gap ="12" >
<k:Form id ="form" >
<k:FormSection title ="Shipment" text ="These details appear on the dispatch list." columns ="2" >
<k:TextField label ="Reference" value ="SH-104" required ="true" />
<k:DateField label ="Dispatch date" required ="true" />
</k:FormSection >
<k:FormSection title ="Handling" >
<k:Check text ="Handle with care" />
</k:FormSection >
</k:Form >
<k:Button kind ="primary" text ="Save shipment" press =".onSave" />
</k:Stack > sap.ui.define(["sap/ui/core/mvc/Controller" , "kor/ui/Toast" ], (Controller, Toast) => Controller.extend("sample.ValidateForm" , {
onSave() {
if (this .byId("form" ).validate()) Toast.show("Form saved" );
}
}));
API Properties Name Type Default Description stackedbooleanfalseWhether section titles sit above the fields
Aggregations Name Type Description sectionsFormSection[]Form sections
Methods Name Description getFields(): Control[]Returns the fields in the form validate(): booleanMarks empty required fields, focuses the first invalid field and returns whether every required field is filled
A labeled group of fields in a form.
Properties Name Type Default Description titlestringSection title textstringSection description columnsint2Number of field columns
Aggregations Name Type Description contentsap.ui.core.Control[]Fields and other controls in the section
Related TextField DateField FileDrop