CFARGUMENT  
Description

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

 
Category

Extensibility tags

 
Syntax
    <cfargument 
   name="..." 
   type="..." 
   required="..." 
   default="..." 
   ...>

  
 
See also

cfcomponent, cffunction, cfinvoke, cfinvokeargument, cfobject, cfproperty, cfreturn

 
Usage

This tag must be positioned before any other tags within the cffunction tag.

Arguments that are passed when a method is invoked can be accessed from the method body in the following ways:

  • With shorthand syntax: #myargument#(This example accesses the argument myargument.)
  • Using the arguments scope as an array: #arguments[1]#(This example accesses the first defined argument in the cffunction)
  • Using the arguments scope as a struct: #arguments.myargument#(This example accesses the argument myargument in the array)
NAME  
  Required
 

String; an argument name.

TYPE  
  Optional
 
Default value: "any"

String; a type name; data type of the argument.

  • any
  • array
  • binary
  • boolean
  • date
  • guid
  • numeric
  • query
  • string
  • struct
  • uuid
  • variableName
  • a component name

If the value is not a recognized type, ColdFusion processes it as a component name.

REQUIRED  
  Optional
 
Default value: "no"

Whether the parameter is required in order to execute the component method.

  • yes
  • no
DEFAULT  
  Optional
 

A type; if no argument is passed, specifies a default argument value.

If this attribute is present, the required attribute must be set to "no" or not specified.