cfargument

Creates a parameter definition within a component definition. Defines a function argument. Used within a cffunction tag.

  <cfargument name="">

 myFunction(required any myArgument){}

Attribute Reference

name string
Required

An argument name.

type string

a type name; data type of the argument.
Values:
  • any
  • array
  • binary
  • boolean
  • component
  • date
  • email
  • function
  • float
  • guid
  • integer
  • numeric
  • query
  • string
  • struct
  • uuid
  • xml
  • variablename
  • (component name)

required boolean
Default: no

Whether the parameter is required to execute the component method.
Values:
  • true
  • false

default string

If no argument is passed, specifies a default argument value.

displayname string

Meaningful only for CFC method parameters. A value to be displayed when using introspection to show information about the CFC.

hint string

Meaningful only for CFC method parameters. Text to be displayed when using introspection to show information about the CFC. The hint attribute value follows the displayname attribute value in the parameter description line. This attribute can be useful for describing the purpose of the parameter.

Examples
Sample code using the cfargument tag

For Script syntax the argument is inside the ()

public boolean function myFunction(required any myArgument) {
    // Some function bits
    return true;
}

For Tag syntax the argument is its own tag

<cffunction access="public" returntype="boolean" name="myFunction">
    <cfargument required="true" type="any" name="myArgument">
    <!--- Some function bits --->
    <cfreturn true>
</cffunction>

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub