Events

Events allows to extend plugin with 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

Note: if you want to skip saving records to database, check "Skip DB" on "Advanced Settings" from the component properties.

  • More info on this: PR#63.