xforms:inputAdded by IBM on October 10, 2012 | Version 1 (Original)
|Links a field, combobox or check box to an element in the data model so that they share data. However, the xforms:input only support a single line of data. Tags: xforms:input option, options, XForms, input: creating XForms inputs, check
item, combobox item, field item, custom item, XFDL, 8.0, spec
For example, if you added an xforms:input option to a field in your form, you could use that option to link the field to a name element in your data model. Once linked, any changes made to the data in one would be reflected by the other.
This option is only available if you are using an XForms data model.
Table 1. xforms input parameters
|single node binding||string||see Single node binding.|
|label text||string||sets the text for the item's built-in label, as well as the accessibility message for the item. Although the xforms:label tag must appear, you can use an empty string if you do not want to set the label.
If the item also has a label or acclabel option, they will override this setting.|
|Alert, Hint, Help Setting||metadata||see Metadata sub-options.|
Available in check, combobox, field, custom
Example The following code shows an XForms model that contains a name, age, and birth date element:
Using that data model, the following code links a field to the name element in the data model, so that they share data:
Once you have a basic field, you can add a help message to it. In the following example, the <xforms:hint> element is used to provide some simple help for the user:
You can also add an alert, in case the user enters the wrong type of data. For instance, the following example creates a field that links to the age node in the data model above and has a data type of integer. Additionally, there is an alert that will appear if the user tries to enter the wrong data type:
<xforms:hint>Enter your full name.</xforms:hint>
To get the user's birth date, you can use a combobox instead of a field. In this case, we will create a combobox with no cells, and set the value option using the date function. This causes the combobox to display a date picker widget when opened.
<xforms:alert>You must enter an integer value.</xforms:alert>
- This option limits a field to a single line of input. To create a field that accepts more input, use the xforms:textarea option instead.
- When using xforms:input with a check box item, the on or off values of the check box are translated into a Boolean true or false (xsd:boolean) when copied to the data model.
- When using xforms:input with a combobox item, the combobox must have an XFDL data type of date.
- Any item with an xforms:input option can trigger XForms actions using the xforms-value-changed event. For more information, refer to XForms event handlers.
- When you add an xforms:input to a custom item, it works just as though it was placed in a valid XFDL item. This means that a value option is created and is linked to the data model.
- Pressing the Enter key in a single line field will commit the value that has been typed to the form. This means it will be copied to the XForms model.