View comments | RSS feed
Contents > CFML Reference > ColdFusion Tags > cfassociate PreviousNext

cfassociate

Allows subtag data to be saved with a base tag. Applies only to custom tags.

Application framework tags

<cfassociate 
baseTag = "base_tag_name"
dataCollection = "collection_name">

cfapplication, cferror, cflock, cfmodule

Attribute

Req/Opt

Default

Description

baseTag

Required

 

Base tag name

dataCollection

Optional

AssocAttribs

Structure in which base tag stores subtag data

Call this tag within a subtag, to save subtag data in the base tag.

When ColdFusion passes subtag attributes back to the base tag, it saves them in a structure whose default name is AssocAttribs. To segregate subtag attributes (in a base tag that can have multiple subtags), specify a structure name, in the dataCollection attribute. The structure is appended to an array whose name is thistag.collectionName.

Within the custom tag code, the attributes passed to the tag by using the attributeCollection attribute are saved as independent values, with no indication that they are grouped into a structure by the custom tag's caller. Therefore, in the called tag, if you assign a value to a specific attribute, it replaces the value passed in the attributeCollection attribute that you used when calling the subtag.

<!--- Find the context --->
<cfif thisTag.executionMode is "start">
 <!--- Associate attributes --->
 <cfassociate baseTag = "CF_TAGBASE">

 <!--- Define defaults for attributes --->
 <cfparam name = "attributes.happy" default = "Yes">
 <cfparam name = "attributes.sad" default = "No">
...

Contents > CFML Reference > ColdFusion Tags > cfassociate PreviousNext

ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6.1

Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.

Comments


isaac dealey said on Aug 28, 2003 at 6:03 PM :
Unfortunately documentation for this tag is somewhat lacking...
Probably owing to its infrequent use...

That being said these are my pointers:
1) the basetag attribute should always be formatted as "cf_mytag" which will work the same even when using cfmodule or cfimport syntax
2) if the CFMX engine doesn't find the base tag it will produce the error message "base tag did not expose any data" (which confused me because I expected "base tag not found" or something similar)
3) to clarify: to access data from the sub-tag within the base tag using thistag.collectionName remember this variable will always be an array of structures, so that if there are multiples of the same sub-tag
the array will contain multiple structures - thus if the sub-tag cf_input contains only <cfassociate basetag="cf_form" dataCollection="input">
the syntax to get the name attribute of the first cf_input tag within cf_form is #thistag.input[1].name#
isaac dealey said on Aug 29, 2003 at 4:26 PM :
In my last comment I forgot to mention that
while I'm not sure why cfapplication, cferror and
cflock are listed as related tags, the functions
getbasetagpath() and getbasetagdata() really
ought to be included in the "see also" for this tag

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6.1/htmldocs/tags-pa5.htm