Table or div << ^ CMS module: MPForm (Homepage of the module) ^ >> Loops in Forms
MPForm Documentation: Private Functions
Level of difficulty: C
A module for Website Baker can solve many tasks for many users. But some customers do have wishes or needs which require special functionalities. Even on the same web site multiple forms might exist, which need to react differently. To be able to act on a flexible way, interfaces to some private functions are build into MPForm. Those functions belong into the file private.php. The advantage of the bundling of the own (private) program code into a single file should be clear: Otherwise you would need to compare the differences of old and new source code before an upgrade, and need to copy each change onto the correct place in the new files. By outsourcing all changes into the file private.php you can skip this work. Currently the file private.php will be overwritten with each update, so make a backup of this file bevor you upgrade MPForm!
The following private functions are defined currently:
- private_function_before_new_form
- Will be called before a form will be assembled. Here you can, for instance, set the current date in a field.
- private_function_before_email
- Will be called after a form has been submitted successfully, but before it will be saved or sent by email. Here you can, for instance, change a message text.
- private_function_on_success
- Will be called after a form has been submitted and saved successfully. Here you can, for instance, change the following page dynamically.
When the function should not do the same action for every form, you should first check the variable $section_id and only when it matches, the required actions should be run. This variable is the only argument which is provided as parameter to the private functions.
The return value should be either true or false. Currently, only both last functions do use it. FALSE does break the regular program flow here.
On the next page I introduce an example I already used in real life sometimes: creating a form loop.
Deutsch
English