How to create an XBL control that saves data in two elements?
I'm trying to tell Orbeon to group 2 fields together in order to capture 2 values as in: Pounds & Ounces.
<xs:complexType name="rpm-weight"> <xs:sequence> <xs:element name="weight-lbs" type="rpm-weight-lbs" minOccurs="1" maxOccurs="1"/> <xs:element name="weight-oz" type="rpm-weight-oz" minOccurs="1" maxOccurs="1"> </xs:sequence> </xs:complexType>
How can I tell Orbeon that when selecting rpm-weight, it will generate 2 text boxes?
Creating an XBL component is the way to go, which might be tricky if this is the first time you're doing this. A few pointers:
- So you can use it in Form Builder, your component needs to bind to one element (with ref). The name of the element will be the name given by form authors to the control in Form Builder (assuming they're not using a custom instance).
- Form Builder will create one element in the instance for the control. Since your control needs to have sub-elements, you need to tell Form Builder about those. You can do that using the fb:metadata/fb:template/fb:instance. See for instance how this is done in autocomplete.xbl. E.g. that part of the metadata will look as follows.
Example Form Builder metadata for the XBL:
<fb:metadata xmlns:fb="http://orbeon.org/oxf/xml/form-builder"> ... <fb:templates> <fb:instance> <weight-lbs/> <weight-oz/> </fb:instance> <fb:view> ... </fb:view> </fb:templates> </fb:metadata>