- Init
- postInit
Called after the module is fully initialized
- postInit
- Get
- actionPreGetErrorCheck
Called before the error checking is done when gathering data - actionPostGetErrorCheck
Called after the error checks are successfully done when gathering data - actionPreGet
Called after the error checks where successfully done and right before gathering data - actionPostGet
Called after successfully gathering data - actionPreGetReferences
Called after the main module data was gathered successfully and right before gathering reference data - actionPostGetReferences
Called after successfully gathering reference data
- actionPreGetErrorCheck
- Submit
- actionPreSubmitErrorCheck
Called before the error checking is done when submitting data - actionPostSubmitErrorCheck
Called after the error checks are successfully done when submitting data - actionPreSubmit
Called after the error checks where successfully done and right before submitting data - actionPostSubmit
Called after successfully submitting data
- actionPreSubmitErrorCheck
The action should be replaced with the relevant action for it to be executed. So if you want to do additional check when adding a new "note" simply add the "addPreSubmitErrorCheck" function to the module and add your business logic in that function.
If a MSF returns "false" the gathering/submitting of the data will stop immediately. Be sure to add relevant feedback (e.g. add an error to the error object ($this->data->e->add("Error")). If you want to continue the gathering/submitting of the data after the MSF is executed you should return "true".
Here's a quick example of MSF as described above:
Notes module with MSF
PHP
require_once($_path["include"]."module.php");class Module_notes extends Module
{
function __construct(&$data)
{
parent::__construct($data);
$this->data->title="Note";
$this->data->defaultFields();
$this->data->addField("title", "text", "all", "title", 1, 25, false, "Title");
$this->data->addField("text", "text", "all", "markup", 0, 65536, false, "Note");
}
function addPreSubmitErrorCheck()
{
for($c=0;$c<$this->data->vmax;$c++) //loop through all submitted values
{
if(containsDirtyWords($this->data->getValue("text", $c))) //do your validation
{
$this->e->add("The text for entry ".$c." contains dirty words.", "error"); //provide feedback on why adding a new note failed
return false; //ensure the submitting the notes are stopped
}
}
return true; //all good, continue with submitting the notes
}
}