ardent
ardent copied to clipboard
afterValidate hook doesn't stop saving using updateUniques() when returning false
I have the following method in my model:
public function afterValidate() {
if(!$this->is_staff && $this->is_preview_user) {
$this->validationErrors->add('is_preview_user', 'Only staff can be preview users');
return false;
}
return true;
}
I used xdebug to walk through it, and even if it returns false the model saves just fine.
Update save() and validate() correctly return false, it's just updateUniques() that misbehaves.
After some snooping around in the code, I realized that the issue is that $this->fireModelEvent('validating') returns null instead of false.