Binding data in Flash forms

The bind attribute lets you set the value of the fields using the contents of other form fields. You can use the bind attribute with the cftextarea tag and any cfinput type that takes a value, including hidden. This data binding occurs dynamically as the user enters data within Flash on the client system. Flash does not send any information to ColdFusion until the user submits the form. To use the bind attribute to specify the field value, use the following formats:

Data source

bind attribute format

cfinputtype="text" or cftextarea text

bind="{sourceName.text}"

cfinput selected radio button

bind="{sourceName.selectedData}"

cftree selected item

bind="{sourceName.selectedNode.getProperty('data').value}

cfgrid selected item

bind="{sourceName.selectedItem.COLUMNAME}"

cfselect selected item

bind="{sourceName.selectedItem.data}"

Note: If you use the bind attribute, you cannot use the value attribute.

The following rules and techniques apply to the binding formats:

  • The sourceName value in these formats is the name attribute of the tag that contains the element that you are binding to.

  • You can bind to additional information about a selected item in a tree. Replace value with display to get the displayed value, or with path to get the path to the node in the tree.

  • You can bind to the displayed value of a cfselect item by replacing data with label.

  • If the user selects multiple items in a cfselect control, the selectedItem object contains the most recent selection, and a selectedItems array contains all selected items. You can access the individual values in the array, as in myTree.selectedItems[1].data. The selectedItems array exists only if the user selects multiple items; otherwise, it is undefined.

  • You can use ActionScript expressions in Flash bind statements.

    The following example shows how to use the values from the firstName and lastName fields to construct an e-mail address. The user can change or replace this value with a typed entry.

    <cfformgroup type="horizontal" label="Your Name"> 
        <cfinput type="text" required="Yes" name="firstName" label="First" 
            value="" width="100"/> 
        <cfinput type="text" required="Yes" name="lastName" label="Last" 
            value="" width="100"/> 
    </cfformgroup> 
    <cfinput type="text" name="email" label="email"  
        bind="{firstName.text}.{lastName.text}@mm.com">