Events
Events allows to extend plugin with your own custom functionalities.
You will be able to:
- modify form data before it's stored to the database
- change components behavior
- use Magic Forms as frontend for your custom plugins
Available events are:
beforeSaveRecord
afterSaveRecord
Usage
Create your custom plugin and extend from the boot method:
public function boot() {
# Change form data before save on database
Event::listen('martin.forms.beforeSaveRecord', function (&$formdata, $component) {
$formdata['somefield'] = "NEW VALUE";
});
# Print database record after saved
Event::listen('martin.forms.afterSaveRecord', function (&$formdata, $component) {
var_dump($formdata);
});
}
Magic Form Extender
This plugin serves as a template to quickly extend Magic Forms.
You can grab here: https://github.com/skydiver/october-plugin-formsextender
Simply clone to plugins/martin/formsextender
, open Plugin.php
and change boot method as you wish.
Notes
If you want to skip saving records to database, check "Skip DB" on "Advanced Settings" from the component properties.
More info
Check PR #63 to get extra information of this feature.