Handling Form Variables Dynamically - Part One
Author: Andrew MullerEvery time you submit a form an additional variable within the form scope called "formfields" is created and passed on to the form's action page.
This is a comma-separated list of the field names from that form.
The list may not be complete as there are three types of form controls that do not get passed to the action page at submission without a value: unchecked checkboxes, multiple select controls with nothing selected and radio button sets that do not have an assigned default.
Additional submit buttons that are not clicked on the form also have the same problem.
CFPARAM addresses this problem easily, with the least amount of code. It allows a developer to bring a specific variable into existence within the appropriate scope should it not available at runtime.
In our sample code CFPARAM takes two attributes, NAME is the variable that we are checking for, DEFAULT is the value that we wish to assign to it.
This single line of code does the same work as the following:
In the case of forms CFPARAM is placed at the top of the form's action page and should the required variable be not available after the form's submission the tag will create the variable and assign it the appropriate value.
Using the variable's name is not enough for the tag to place within the form scope. Without a prefix the variable will be placed in the local or "variables" scope. We need to add the form prefix so that it is available correctly.
CFPARAM is useful also in the testing and development phase as it allows a developer to quickly create required external variables without necessarily going through the browser process first.

