Text field component of form that allows users to provide formatted numbers. To implement, you use the number-input key.
Here is a structure, which has a property age that can be populated with a number-input element in a form:
structure (Survey) {
property (fullName) {
type (FullName)
min (Required) max (One)
}
property (email) {
type(Email)
min (Required) max(One)
}
property (comments) {
type (Comments)
min (Optional) max (One)
}
property (isSigningUp) {
type (IsSigningUp)
min (Required) max (One)
}
property (favoriteColors) {
type (FavoriteColors)
min (Required) max (One)
}
property (funMeter) {
type (FunMeter)
min (Required) max (One)
}
property (age) {
type (Age)
min (Required) max (One)
}
}For an input view of a number-input:
input-view {
match {
Age (age) {
to-input: SubmitSurvey
}
}
message {
template ("What is your age?")
}
render {
form {
elements {
number-input {
id (age)
allow-negative (false)
integer-limit (3)
type (Age)
label (Age)
}
}
on-submit {
goal: Age
value: viv.core.FormElement(age)
}
}
}
}
You can run the sample capsule in the Simulator to see how this component displays on different devices, if supported.
| id required | Unique identifier to map between an element in the form and property values set in the on-submit intent container |
| type required | Concept type of element being inputted |
| allow-negative optional | Boolean |
| decimal-limit optional | Number of decimal places allowed in formatted number |
| decimal-symbol optional | Symbol to denote fractions of a number |
| integer-limit optional | Number of integers allowed in format |
| label optional | Text label of form element |
| prefix optional | Prefix to prepend to inputted number |
| required optional | Boolean |
| suffix optional | Suffix to append to inputted number |
| thousands-separator optional | Symbol to separate thousands by |
| value optional | Initial value of element |