The XForms data model specifies the data that the form submits. It includes information on each displayed control that can submit data, including initial values and validation information. It does not contain information about cfformgroup
or cfformitem
tags. The data model consists of the following elements and their children:
xf:instance
element
xf:submission
element
xf:bind
element for each form control that can submit data
The XForms xf:instance
element contains information about the form data controls. Any control that can submit data has a corresponding instance element. If the control has an initial value, the instance element contains that value.
The xf:instance
element contains a single cf:data
element that contains an element for each data control: cfgrid
, most cfinput
tag types, cfselect
, cfslider
, cftextarea
, and cftree
. Each element name is the corresponding CFML tag's name
attribute. For applet and Flash format cfgrid
and cftree
tags, the element name is the value of the cf_param_name
parameter of the tree or grid's Java applet object. Only cfinput
tags of types submit
, image
, reset
and button
do not have instance data, because they cannot submit data.
Each element's body contains the initial control data from the CFML tag's value
attribute or its equivalent. For example, for a cfselect
tag, the xf:instance
element body is a comma-delimited list that contains the name
attributes of all the option
tags with a selected
attribute. For submit
and image
buttons, the body contains the name
attribute value.
The following example shows the xf:instance
element for the form shown in the figure in About XML skinnable forms:
<xf:instance> <cf:data> <firstname/> <lastname/> <email/> <revision>Comment Form revision 12a</revision> <satisfaction>very satisfied</satisfaction> <thoughts>We really want to hear from you!</thoughts> </cf:data>
The xf:submission
element specifies the action when the form is submitted, and contains the values of the cfform
action
and method
attributes.:
The following example shows the XML for the form shown in the figure in About XML skinnable forms:
<xf:submission
action="/_MyStuff/phase1/forms/XForms/FrameExamples/Figure1.cfm" method="post"/>
The xf:bind
elements provide information about the input control behavior, including the control type and any data validation rules. The XML has one bind element for each instance element that can submit data. It does not have bind elements for controls such as cfformitem
tags, or cfinput
tags with submit, input, reset, or image types. Each element has the following attributes:
Attribute | Description |
---|---|
id |
CFML tag |
nodeset |
XPath expression with the path in the XML to the instance element for the control |
required |
CFML tag |
Each xf:bind
element has an xf:extension
element with ColdFusion specific information, including type and validation values. The following table lists the cf namespace elements that are used in this section:
Element | Description |
---|---|
cf:attribute name="type" |
Control type. One of the following: CHECKBOX, FILE, IMAGE, PASSWORD, RADIO, SELECT, SUBMIT TEXT, CFSLIDER. The TEXT type is used for |
cf:attribute name="onerror" |
JavaScript function specified by the control's |
cfargument name="maxlength |
Value of the control's |
cf:validate type="valiadationtype" |
Data validation information. Has one attribute,
|
cf:argument (in the body of a cf:validate element) |
Data validation specification. Has one attribute, Valid
|
cf:trigger (in the body of a cf:validate element) |
When to do the validation; specifies a form element Has one attribute,
If a |
The following example shows the xf:bind
element of the form shown in the figure in About XML skinnable forms:
<xf:bind id="firstname" nodeset="//xf:model/xf:instance/cf:data/firstname" required="true()"> <xf:extension> <cf:attribute name="type">TEXT</cf:attribute> <cf:attribute name="onerror">_CF_onError</cf:attribute> </xf:extension> </xf:bind> <xf:bind id="lastname" nodeset="//xf:model/xf:instance/cf:data/lastname" required="true()"> <xf:extension> <cf:attribute name="type">TEXT</cf:attribute> <cf:attribute name="onerror">_CF_onError</cf:attribute> </xf:extension> </xf:bind> <xf:bind id="email" nodeset="//xf:model/xf:instance/cf:data/email" required="false()"> <xf:extension> <cf:attribute name="type">TEXT</cf:attribute> <cf:attribute name="onerror">_CF_onError</cf:attribute> </xf:extension> </xf:bind> <xf:bind id="satisfaction" nodeset="//xf:model/xf:instance/cf:data/satisfaction" required="false()"> <xf:extension> <cf:attribute name="type">SELECT</cf:attribute> <cf:attribute name="onerror">_CF_onError</cf:attribute> </xf:extension> </xf:bind> <xf:bind id="thoughts" nodeset="//xf:model/xf:instance/cf:data/thoughts" required="false()"> <xf:extension> <cf:attribute name="type">TEXT</cf:attribute> <cf:attribute name="onerror">_CF_onError</cf:attribute> </xf:extension> </xf:bind>