diff --git a/src/Database/Traits/Validation.php b/src/Database/Traits/Validation.php index 15d821902..bccaca799 100644 --- a/src/Database/Traits/Validation.php +++ b/src/Database/Traits/Validation.php @@ -70,11 +70,15 @@ public function initializeValidation() } $this->bindEvent('model.saveInternal', function() { + $validationForced = $this->validationForced; + + if (($forceOption = $this->getSaveOption('force')) !== null) { + $this->validationForced = $forceOption; + } + // If forcing the save event, the beforeValidate/afterValidate // events should still fire for consistency. So validate an // empty set of rules and messages. - $this->validationForced = $this->getSaveOption('force', false); - if ($this->validationForced) { $valid = $this->validate([], []); } @@ -82,6 +86,8 @@ public function initializeValidation() $valid = $this->validate(); } + $this->validationForced = $validationForced; + if (!$valid) { return false; }