Ad

OctoberCMS | Extra Actions During Creation Into Plugin Created On "Builder"

Imagine that I have a Plugin Gallery that was made on Builder, and after creation of Slide I want to do some extra actions...

Imagine that I want to create another Slide with some changes to another plugin... (After redirect to /update/:id)

So as I understand I need to extend a Constructor?

I need something like adding an extra class to a <body>...

Here's an example:

public function update($id) {
    $this->bodyClass = 'compact-container';
    return $this->asExtension('FormController')->update($id);
}

this function is called before the generation of a page, and I need something similar after creation of a "Slide"

Ad

Answer

I have analyzed file modules/backend/behaviors/FormController.php and I found these functions, that can help me to do some extra actions after and before creating things on some plugins:

/**
 * Called before the creation or updating form is saved.
 * @param Model
 */
public function formBeforeSave($model)
{
}

/**
 * Called after the creation or updating form is saved.
 * @param Model
 */
public function formAfterSave($model)
{
}

All I need to do, is put those function into my controller's file

Ad
source: stackoverflow.com
Ad