How to make the formwidget save the data only after the model is saved?
How to make the rain fall only after the ground is wet?
How to call a function in formwidget after saving model data?
P/S Sorry, translate via google translate
@Cryden, start from reading documentation first: https://octobercms.com/docs/database/model#events
i can use in formWidget this code?
public function init()
{
Event::listen('model.afterSave', function() {
// My function code run after Save model
});
}
@cryden you could, but it would be better to target the specific model being touched by the form. Try something like this:
public function init()
{
$this->model->bindEvent('model.afterSave', function () use ($model) {
// your custom code here
});
}
Thanks!