Data model



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:

  • One xf:instance element

  • One xf:submission element

  • One xf:bind element for each form control that can submit data

xf:instance element

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, andbutton do not have instance data, because they cannot submit data.

The body of each element 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 image 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> 
</xf:instance>

xf:submission element

The xf:submission element specifies the action when the form is submitted, and contains the values of the cfformaction and method attributes.:

The following example shows the XML for the form shown in the image in About XML skinnable forms:

<xf:submission action="/_MyStuff/phase1/forms/XForms/FrameExamples/Figure1.cfm" 
    method="post"/> 

xf:bind elements

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 name attribute value

nodeset

XPath expression with the path in the XML to the instance element for the control

required

CFML tag required attribute value

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 here.

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 cfinputtype="text" and cftextinput.

cf:attribute name="onerror"

JavaScript function specified by the control’s onError attribute, if any.

cfargument name="maxlength"

Value of the control’s maxlength attribute, if any.

cf:validate type="valiadationtype"

Data validation information.

Has one attribute, type, the validation type, and one or more cf:argument and cf:trigger children. ColdFusion generates a cf:validate element for each of the following:

  • cfinput or cftextareavalidation attribute

  • cfinput or cftextarearange attribute

  • cfslider: the range and message attributes are specified by a cf:validate type="range" element

cf:argument

(in the body of a cf:validate element)

Data validation specification.

Has one attribute, name, and body text. Each cf:validate element can have multiple cf:argument children, corresponding to the validation-related CFML tag attribute values, such as maximum length, and maximum and minimum range values. The element body contains the CFML attribute value.

Valid name values are as follows. Unless specified otherwise, the name is identical to the corresponding CFML tag attribute name.

  • max

  • message

  • min

  • pattern

cf:trigger

(in the body of a cf:validate element)

When to do the validation; specifies a form element validateAt attribute value.

Has one attribute, event, which can be one of the following:

  • onBlur

  • onSubmit

  • onServer

If a validateAt attribute specifies multiple validation triggers, the XML has one cf:trigger element for each entry in the list.

The following example shows the xf:bind element of the form shown in the image 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>