getValue()
gets current values/states of controls
getValue(asFormData?: boolean): object;
Parameters:
asFormData: boolean
- optional, defines whether values of Form controls should be returned as Form Data
Returns:
An object either with the names or IDs of controls (if the name attribute is not defined in the config of the control) and their values/states.
Example
const state = form.getValue();
// -> {"name":"John Doe"}
Related sample: Form. Get value
1. In case both the name and id of the control are specified in the config of Control, the returned object will contain the name of Control:
const state = form.getValue();
// -> {"name":"John Doe"}
If the name attribute is not specified in the controls config, an object with ID of Control will be returned:
const state = form.getValue();
// -> {"id":"John Doe"}
2. Starting with v7.0, the type of the returned value for the TimePicker control depends on the applied valueFormat and timeFormat:
- If
valueFormat: "string"
andtimeFormat:24
are specified, a return string value will include just the hour and minutes: "00:39" - If
valueFormat: "string"
andtimeFormat:12
are specified, a return string value will include hour, minutes, and am/pm identifiers: "06:00AM" - If
valueFormat: "timeObject"
andtimeFormat:24
are specified, a return object value will containkey:value
pairs for hours, minutes and their values:{hour: 0, minute: 39}
- If
valueFormat: "timeObject"
andtimeFormat:12
are specified, a return object value will containkey:value
pairs for hours, minutes, am/pm identifiers and their values:{hour: 6, minute: 0, AM: true}