cfargument

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

 <cfargument name="">

 myFunction(required any myArgument){}

cfargument Attribute Reference

name
Required

An argument name.

type

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

required
Default: no

Whether the parameter is required to execute the component
method.

default

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

displayname

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

hint

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


Script Syntax

For Script syntax the argument is inside the ()

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

Tag Syntax

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>

Fork me on GitHub