Event before save on pivot relationRender

I have subject form like this

The levels table in the form created using partial view with $this->relationRender('levels')

I want to add some logic before saving the levels

I can’t use beforeSave event model because it is only triggered when saving the subject form, not when saving levels of subject

Is there any way to do it ?

Hi @wibisono.indrawan ,

To perform an action before saving the Level model, you can add a beforeSave method inside the Level model.

If the Level model is not within your plugin, you can extend the Level model by adding the following code to your Plugin.php boot method:

Author\Plugin\Models\Level::extend(function($model) {
    $model->bindEvent('model.beforeSave', function() use ($model) {
        // ...
    });
});