How do I use my own custom programming with ContentMonger's forms?
CMonger has its own form design system that allows ordinary users to create simple or complex forms using a simple menu-driven system. You can even build up libraries of commonly-used form blocks (such as credit card address / number fields, or a drop-down with U.S. states) -- so you don't have to type them in from scratch every single time you use them.
The system will also process the submitted data; storing it in a special form results database and -- if the form was designated secure in the first place -- will even present the data securely to the designated form administrator.
You also have the opportunity to either supplement or entirely replace the CMonger form processor. When yiou create a form you have the option to totally replace the form processor, or specify a form pre-or post-processor (or both) which contains the code of your choosing. Why do this? Here's an easy example: You build a signup form for members, where a credit card will be entered, a card gateway will be queried and, if the card charge is successful, the user will be added into the CMonger system as a privileged visitor with the ability to log in to a certain area (user creators and permission assignment tags are located in the CMonger toolbox). To do such a thing you need to
- collect the submitted form data
- warp out to the gateway and present selected form data to the card processor
- process the gateway's response
- replace certain sensitive form fields with junk data (like the credit card number) to ensure customer security.
YOUR code is going to do the above, and the key to it is to figure out how to pull out the submitted form data that is being sent to the CMonger form processor. You need to do the following.
- When you create your form, take advantage of the "Alias" field to give your form field a recognizable name (CMonger's db-driven form generator will not give you form field names you can count on in external programming... well, it can but its inconvenient and aliasing the field makes more sense). Your alias must conform to ColdFusion variable name rules, and must not include any variable scope -- CMonger will handle that. For example, if your form field contains a first name, alias the field as "firstName". Use "lastName" for fields containing a surname, "creditCardNumber" and so on.
- When you build your form, specify a ColdFusion template as the pre-processor. This will supplement the built-in CMonger processor, which is probably your best bet.
- When CMonger processes the submitted form data, it will return to you a request-scope struct named "request.submitData" where the form data submitted will be in the struct. Your alias names will be individual values in the struct. For example:
Use these values to do whatever you want in your custom code.