cftextarea
Description
Puts a multiline text entry box in a cfform tag and controls its display characteristics. Optionally, displays a rich text editor with configurable controls for formatting HTML text.
Categories
Related
cfajaximport cfapplet cfcalendar cfform cfformgroup cfformitem cfgrid cfinput cfselect cfslider cftree
History
ColdFusion
8:
Added support for the bind attribute
in HTML format forms, including the bindAttribute, bindOnLoad,
and onBindError attributes.
Added support for tool tips in HTML format, including the sourceForTooltip attribute.
Added support for a rich text editor in HTML format, including
the richtext, basepath, fontFormats, fontNames, fontSizes, skin, stylesXML, templatesXML, toolbar,
and toolbarOnFocus attributes and support for the height and width attributes.
ColdFusion
MX 7: Added this tag.
Syntax
<cftextarea
name="name"
basepath="path"
bind="bind expression"
bindAttribute="attribute name"
bindOnLoad="false|true"
disabled="true|false" or no attribute value
enabled="yes|no"
fontFormats="comma separated list"
fontNames="comma separated list"
fontSizes="comma separated list"
height="number of pixels"
html="no|yes"
label="text"
maxlength="number"
message="text"
onBindError = "JavaScript function name"
onChange="JavaScript or ActionScript"
onClick="JavaScript or ActionScript"
onError="script name"
onKeyDown="JavaScript or ActionScript"
onKeyUp="JavaScript or ActionScript"
onMouseDown="JavaScript or ActionScript"
onMouseUp="JavaScript or ActionScript"
onValidate="script name"
pattern="regexp"
range="minimum value, maximum value"
required="yes|no"
richtext="no|yes"
secureUpload="true|false"
skin="default|silver|office2003|custom skin"
sourceForToolTip="URL"
style="style specification"
stylesXML="path"
templatesXML"path"
toolbar="Default|Basic|custom toolbar"
toolbarOnFocus"no|yes"
tooltip="tip text"
validate="data type"
validateAt= one or more of "onBlur, onServer, onSubmit"
value="text"
visible="yes|no"
width="number of pixels"
wrap="off|hard|soft|virtual|physical">
text
</cftextarea>
Some attributes apply to only
specific display formats. For details see the Attributes table.
Note: You can specify this tag’s attributes in an attributeCollection attribute
whose value is a structure. Specify the structure name in the attributeCollection attribute
and use the tag’s attribute names as structure keys.
Attributes
| Attribute | Description | Required | Default |
|---|---|---|---|
| basepath | Path to the directory that contains the rich text editor. The editor configuration files are at the top level of this directory. Meaningful only if the richText attribute is true. | Optional; HTML | /CFIDE/scripts/ajax/FCKEditor |
| bind | A bind expression that dynamically sets an attribute of the control. For details, see Usage. | Optional; Flash, HTML | |
| bindAttribute | Specifies the HTML tag attribute whose value is set by the bind attribute. You can only specify attributes in the browser’s HTML DOM tree, not ColdFusion-specific attributes. Ignored if there is no bind attribute. | Optional; HTML | value |
| bindOnLoad | A Boolean value that specifies whether to execute the bind attribute expression when first loading the form. Ignored if there is no bind attribute. | Optional; HTML | no |
| disabled | Disables user input, making the control read-only. To disable input, specify disabled without an attribute, or disabled="Yes" (or any ColdFusion positive Boolean value, such as True). To enable input, omit the attribute or specify disabled="No" (or any ColdFusion negative Boolean value, such as False). | Optional; All | not disabled |
| enabled | Boolean value that specifies whether the control is enabled. A disabled control appears in light gray. The inverse of the disabled attribute. | Optional; Flash | yes |
| fontFormats | A comma-separated list of the font names to display in the rich text editor Formats selector. The formats specify the HTML tags to apply to typed or selected text. You can specify any subset of the following list: "p,div,pre,address,h1,h2,h3,h4,h5,h6". | Optional; HTML | All valid formats |
| fontNames | A comma-separated list of the font names to display in the rich text editor Font selector. You can specify any subset of the following list: "Arial,Comic Sans MS,Courier New,Tahoma,Times New Roman,Verdana". | Optional; HTML | All valid font names |
| FontSizes | A comma-separated list of the font sizes to display in the rich text editor Size selector. List entries must have the format of numeric font size/descriptive text. For example, to display the text "small font" to indicate a font size of 1, specify "1/small font". By default, the following values appear in the selector: 1/xx-small,2/x-small,3/small,4/medium,5/large,6/x-large,7/xx-large. | Optional; HTML | See Description |
| height | In Flash forms, height of the control, in pixels. In HTML forms, this attribute has an effect only if you specify richtext="true"; in this case, it is the height, in pixels, of the control, including the control bar and text box. | Optional; Flash, HTML | |
| html | Boolean value that specifies whether the text area contains HTML. | Optional; Flash | no |
| label | Label to put beside the control on a form. | Optional; Flash and XML | |
| maxLength | The maximum length of text that can be entered. ColdFusion uses this attribute only if you specify maxlength in the validate attribute. | Optional; All | |
| message | Message text to display if validation fails. | Optional; All | |
| name | Name of the cftextinput control. | Required; All | |
| onBindError | The name of a JavaScript function to execute if evaluating a bind expression results in an error. The function must take two attributes: an HTTP status code and a message. (The status code is -1 if the error is not an HTTP error.) If you omit this attribute, and have specified a global error handler (by using the ColdFusion.setGlobalErrorHandler function), it displays the error message; otherwise a default error pop-up displays. | Optional; HTML | See Description |
| onChange | JavaScript (HTML/XML) or ActionScript (Flash) to run when the control changes due to user action. | Optional; All | |
| onClick | JavaScript to run when the user clicks the control. | Optional; HTML and XML | |
| onError | Custom JavaScript function to execute if validation fails. | Optional; HTML and XML | |
| onKeyDown | JavaScript (HTML/XML) or ActionScript (Flash) ActionScript to run when the user presses a keyboard key in the control. | Optional; All | |
| onKeyUp | JavaScript (HTML/XML) or ActionScript (Flash) to run when the user releases a keyboard key in the control. | Optional; All | |
| onMouseDown | JavaScript (HTML/XML) or ActionScript (Flash) to run when the user releases a mouse button in the control. | Optional; All | |
| onMouseUp | JavaScript (HTML/XML) or ActionScript (Flash) to run when the user presses a mouse button in the control. | Optional; All | |
| onValidate | Custom JavaScript function to validate user input. The JavaScript DOM form object, input object, and input object value are passed to the function, which must return True if validation succeeds, False otherwise. If you specify this attribute, ColdFusion ignores the validate attribute. | Optional; HTML and XML | |
| pattern | JavaScript regular expression pattern to validate input. Omit leading and trailing slashes. ColdFusion uses this attribute only if you specify regex in the validate attribute. For examples and syntax, see Building Dynamic Forms with cfform Tags in the Developing ColdFusion Applications. | Required if validate = "regular_expression" HTML and XML. | |
| range | Minimum and maximum allowed numeric values. ColdFusion uses this attribute only if you specify range in the validate attribute. If you specify a single number or a single number followed by a comma, it is treated as a minimum, with no maximum. If you specify a comma followed by a number, the maximum is set to the specified number, with no minimum. | Optional; All | |
| required | yes: the field must contain text. no: the field can be empty. | Optional; All | no |
| richText | A Boolean value specifying whether this control is a rich text editor with tool bars to control the text formatting. For detailed information on using the rich text editor, see Using the rich text editor in the Developing ColdFusion Applications. | Optional; HTML | no |
| secureUpload | If true, enables secure upload using FCKeditor. For secure upload, you must have sessionManagement set to yes. Secure upload does not work if sessionManagement is set to false. If you do not use FCKeditor, Adobe recommends that you set config.enabled=false in the config.cfm available in the FCKeditor folder in cf_webRoot. | Optional | true |
| skin | Specifies the skin to be used for the rich text editor. By default, the valid values are default, silver, and office2003. You can also create custom skins that you can then specify in this attribute. For more information, see Using the rich text editor in the Developing ColdFusion Applications. | Optional; HTML | default |
| sourceForTooltip | The URL of a page to display as a tool tip. The page can include CFML and HTML to control the contents and format, and the tip can include images. If you specify this attribute, an animated icon appears with the text "Loading..." while the tip is being loaded. | Optional; HTML | |
| style | In HTML or XML format forms, ColdFusion passes the style attribute to the browser or XML. In Flash format forms, must be a style specification in CSS format, with the same syntax and contents as used in Flex for the corresponding Flash element. | Optional; All | |
| stylesXML | The path of the file that defines the styles in the rich text editor Styles selector. Relative paths start at the directory that contains the fckeditor.html file, normally cf_webRoot/CFIDE/scripts/ajax/FCKeditor/editor. You can specify an absolute path starting at the web root, such as /myApps/RTEeditor.mystyles.xml. For information on configuring styles, see Using the rich text editor in the Developing ColdFusion Applications. | Optional; HTML | /CFIDE/scripts/ajax/FCKEditor/fckstyles.xml |
| templatesXML | The path of the file that defines the templates that are displayed when you click the rich text editor Templates icon. For pathing details, see stylesXML. For information on configuring templates, see Using the rich text editor in the Developing ColdFusion Applications. | Optional; HTML | /CFIDE/scripts/ajax/FCKEditor/fcktemplates.xml |
| toolbar | Specifies the rich text editor toolbar. By default, the valid values for this attribute are: Default, a complete set of controls, and Basic, a minimal configuration. You can add configurations; for details see Using the rich text editor in the Developing ColdFusion Applications. Note: This attribute’s value is case sensitive. | Optional; HTML | Default |
| toolbarOnFocus | A Boolean value that specifies whether the rich text editor toolbar expands and displays its controls only when the rich text editor has the focus. | Optional; HTML | no |
| tooltip | Text to display when the mouse pointer hovers over the control. Can include HTML formatting. Ignored if you specify a sourceForTooltip attribute. | Optional; Flash, HTML | |
| validate | The type or types of validation to perform. Available validation types and algorithms depend on the format. For details, see the Usage section of the cfinput tag reference. | Optional; All | |
| validateAt | How to do the validation; one or more of the following: onSubmit onServer onBlur For Flash format forms, onSubmit and onBlur are identical; for both, validation is done when the user submits the form. For multiple values, use a comma-delimited list. For details, see the Usage section of the cfinput tag reference. | Optional; HTML and XML | onSubmit |
| value | Initial value to display in text control. You can specify an initial value as an attribute or in the tag body, but not in both places. If you specify the value as an attribute, put the closing cftextarea tag immediately after the opening cftextarea tag, with no spaces or line feeds between, or place a closing slash at the end of the opening cftextarea tag; for example <cftextareaname="description"value="Enteradescription."/>. | Optional; All | |
| visible | Boolean value that specifies whether to show the control. Space that would be occupied by an invisible control is blank. | Optional; Flash | yes |
| width | The width of the control, in pixels. In HTML forms, this attribute has an effect only if you specify richtext="true". | Optional; Flash, HTML | |
| wrap | hard: wraps long lines, and sends the carriage return to the server. off: does not wrap long lines. physical: wraps long lines, and transmits the text at all wrap points. soft: wraps long lines, but does not send the carriage return to the server. virtual: wraps long lines, but does not send the carriage return to the server. | Optional All |
Usage
For this tag to work properly in HTML format. the browser must be JavaScript-enabled.
If you put text in the tag body, the control displays all text characters between the cftextarea opening and closing tags; therefore, if you use line feeds or white space to format your source text, they appear in the control.
If the cfform preserveData attribute is "yes", and the form posts back to the same page, the posted value (not the value of the value attribute) of the cftextinput control is used.
If you put text in the tag body, the control displays all text characters between the cftextarea opening and closing tags; therefore, if you use line feeds or white space to format your source text, they appear in the control.
If the cfform preserveData attribute is "yes", and the form posts back to the same page, the posted value (not the value of the value attribute) of the cftextinput control is used.
Example
This
example has two cftextarea controls. When you submit
the form, ColdFusion copies the text from the first control into
the second. The onBlur maxlength validation prevents you from entering
more than 100 characters. The > character that closes the cftextarea opening
tag, the text in the tag body, and the cftextarea closing
tag are on a single line to ensure that only the desired text displays,
but the line is split in this example for formatting purposes.
<h3>cftextarea Example</h3>
<cfparam name="text2" default="">
<cfif isdefined("form.textarea1") AND (form.textarea1 NEQ "")>
<cfset text2=form.textarea1>
</cfif>
<cfform name="form1">
<cftextarea name="textarea1" wrap="virtual" rows="5" cols="25"
validate="maxlength" validateAt="onBlur" maxlength="100"
>Replace this text. Maximum length is 100 Characters, and this text is
currently 99 characters long.</cftextarea>
<cftextarea name="textarea2" wrap="virtual" rows="5" cols="50" value="#text2#" /><br><br>
<input type="submit" value="submit field"><br>
</cfform>