Browse Source

Fix to handle errors that occur during nested models saving (#23)

tags/1.4.0
Alban Jubert 7 years ago
parent
commit
1fb2da90dd
  1. 1
      src/SaveRelationsBehavior.php

1
src/SaveRelationsBehavior.php

@ -305,6 +305,7 @@ class SaveRelationsBehavior extends Behavior
} catch (Exception $e) {
Yii::warning(get_class($e) . " was thrown while saving related records during beforeValidate event: " . $e->getMessage(), __METHOD__);
$this->_rollback();
$model->addError($model->formName(), $e->getMessage());
$event->isValid = false; // Stop saving, something went wrong
return false;
}

Loading…
Cancel
Save