Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Collections: beforeSave() is being fired on $my_document->delete()

I have found that beforeSave() is being fired when attempting to delete() a document.

Isn't this a bug or a known issue?



25.2k

I neglected to mention that my document has soft deleteable behaviour on it.

Does beforeSave() get executed on delete() with soft deleteable behaviour in Mvc\Models?

Soft delete performs update so it is correct



25.2k

Technically. But semantically?



25.2k
Accepted
answer
edited Mar '16

To branch blocks of validation code depending on the operation made I write within validation():

public funciton validation()
{
    if($this->_operationMade != 2) {
        ... // Validation code
    }
}