Skip to content

Commit

Permalink
Merge pull request #30 from luyadev/allow-delete
Browse files Browse the repository at this point in the history
allow delete and cleanup data
  • Loading branch information
nadar authored Oct 5, 2022
2 parents b59f6cb + 7e9ef1e commit d9d30e8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).
In order to read more about upgrading and BC breaks have a look at the [UPGRADE Document](UPGRADE.md).

## 1.7.1 (5. October 2022)

+ [#30](https://github.com/luyadev/luya-module-forms/pull/30) Added option to delete forms including all values and submissions.

## 1.7.0 (1. September 2022)

+ [#29](https://github.com/luyadev/luya-module-forms/pull/29) Added option to retrieve certain value in submission email object.
Expand Down
17 changes: 15 additions & 2 deletions src/models/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* @property integer $updated_at
* @property integer $created_by
* @property integer $updated_by
*
* @property Submission[] $submissions
* @author Basil Suter <[email protected]>
* @since 1.0.0
*/
Expand Down Expand Up @@ -61,6 +61,19 @@ public function behaviors()
];
}

/**
* {@inheritDoc}
*/
public function init()
{
parent::init();
$this->on(self::EVENT_AFTER_DELETE, function() {
foreach ($this->submissions as $submission) {
$submission->delete();
}
});
}

/**
* @inheritdoc
*/
Expand Down Expand Up @@ -131,7 +144,7 @@ public function ngRestScopes()
return [
['list', ['title', 'recipients']],
[['create', 'update'], ['title', 'recipients', 'subject', 'copy_to_attribute', 'email_intro', 'email_outro']],
['delete', false],
['delete', true],
];
}

Expand Down

0 comments on commit d9d30e8

Please sign in to comment.