TextField
Provides a labeled single-line or multiline input.
When to use
- Collect a short value or a note and show validation beside the field.
Examples
A reference field
Loading the example
<k:TextField label="Reference" placeholder="SO-104" icon="search" change=".onChange"/>sap.ui.define(["sap/ui/core/mvc/Controller", "kor/ui/Toast"], (Controller, Toast) => Controller.extend("sample.TextFieldChange", {
onChange(event) {
Toast.show("Reference updated");
}
}));Validate a packing note
Loading the example
<k:TextField label="Packing note" rows="3" required="true" help="Mention any special packing instructions." change=".onChange"/>sap.ui.define(["sap/ui/core/mvc/Controller", "kor/ui/Toast"], (Controller, Toast) => Controller.extend("sample.TextFieldChange", {
onChange(event) {
const field = event.getSource();
const value = event.getParameter("value").trim();
field.setError(value ? "" : "Enter a packing note.");
if (value) Toast.show("Packing note updated");
}
}));API
Properties
| Name | Type | Default | Description |
|---|---|---|---|
value | string | Field value | |
label | string | Field label | |
placeholder | string | Placeholder | |
help | string | Supporting text | |
error | string | Validation message. A nonempty message marks the field invalid | |
icon | string | Leading icon | |
unit | string | Trailing unit or suffix | |
type | string | text | text, email, tel, url, search, password or date |
rows | int | 1 | Number of rows. More than one creates a multiline field |
required | boolean | false | Whether a value is required |
enabled | boolean | true | Whether the field can be used |
Events
| Name | Type | Description |
|---|---|---|
change | value: string | The value changed when the user left the field |
liveChange | value: string | The user edited the value |