From 1fb2da90dd25e1e006506f6d120d5261bb8bc781 Mon Sep 17 00:00:00 2001 From: Alban Jubert Date: Fri, 10 Nov 2017 14:08:27 +0100 Subject: [PATCH] Fix to handle errors that occur during nested models saving (#23) --- src/SaveRelationsBehavior.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SaveRelationsBehavior.php b/src/SaveRelationsBehavior.php index 33e081a..32405d2 100644 --- a/src/SaveRelationsBehavior.php +++ b/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; }