CFLib.org – Common Function Library Project

deleteFormFields(fieldList)

Last updated June 12, 2003

author

Tom Young

Version: 1 | Requires: CF5 | Library: UtilityLib

Description:
Useful if you need to clean up a form for whatever reason before using the cfinsert or cfupdate tag. Takes a comma-delimited list of form field names as its only argument.

Return Values:
Returns nothing.

Example:

<cfset form.field1 = "foo">
<cfset form.field2 = "goo">
<cfset form.field3 = "zoo">
<cfset form.fieldnames="field1,field2,field3">
<cfdump var="#form#">
<cfset theFields = "field1,field2">
<cfset deleteFormFields(theFields)>
<cfdump var="#form#">

Parameters:

Name Description Required
fieldList List of fields to return. Yes

Full UDF Source:

/**
 * Removes specified fields from a form structure.
 * 
 * @param fieldList      List of fields to return. (Required)
 * @return Returns nothing. 
 * @author Tom Young (tom@thenewmediagroup.com) 
 * @version 1, June 12, 2003 
 */
function deleteFormFields(fieldList) {
    var listIndex = 1;
    var i = 1;
    fieldList = ListToArray(fieldList);
    for(i = 1; i lte ArrayLen(fieldList); i = i + 1) {
        StructDelete(form, fieldList[i]);
        listIndex = ListFindNoCase(form.fieldnames, fieldList[i]);
        form.fieldnames = ListDeleteAt(form.fieldnames, listIndex);
    }
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson