/** * apply hash to password before storing in database */ protected function afterValidate() { parent::afterValidate(); //ensure we don't have any errors if (!$this->hasErrors()) { $this->password = $this->hashPassword($this->password); } }