Visforms Custom Plugin Examples for plugin development with Visforms Events
Below are examples of how to implement and use a Visforms custom plugin.
Caution: The Visforms Custom Plugin Template is constantly evolving. Any type of installation will overwrite the Visforms custom plugin. If you have made changes to the Visforms custom plugin, all changes will be lost without prior confirmation.
Note:
Work with a copy of the Visforms Custom Plugin Template in all situations where you don't want to lose your changes.
How to make a copy of the Visforms Custom Plugin Template is explained here:
Create a copy of the Visforms Custom Plugin Template
Number formatting in email templates for SQL fields
With the following short PHP code you can influence the output format for a given form (ID) and for a given field (ID).
The code responds to both result mail (resultmail) and user mail (receiptmail) email types.
Number formatting in email templates for SQL fields where the options label, unlike the static options label, is not available.
Example: ‘1000.7’ then becomes a German number format without thousands separator ‘1000,70 €’ in the mail text.
public function onVisformsBeforeEmailPrepare($context, $form): bool {
if($form->id == 2) {
$field = $this->getFieldByID($form, 84);
// German notation without thousands separator
$field->dbValue = number_format($field->dbValue, 2, ',', '') . ' €';
}
return true;
}