1818trait RelationTrait
1919{
2020
21- public function loadAll ($ POST )
21+ public function loadAll ($ POST , $ skippedRelations = [] )
2222 {
2323 if ($ this ->load ($ POST )) {
2424 $ shortName = StringHelper::basename (get_class ($ this ));
@@ -33,6 +33,10 @@ public function loadAll($POST)
3333 $ relModelClass = $ rel ->modelClass ;
3434 $ relPKAttr = $ relModelClass ::primaryKey ();
3535 $ isManyMany = count ($ relPKAttr ) > 1 ;
36+
37+ if (in_array ($ relName , $ skippedRelations ))
38+ continue ;
39+
3640 if ($ isManyMany ) {
3741 $ container = [];
3842 foreach ($ value as $ relPost ) {
@@ -76,7 +80,7 @@ public function loadAll($POST)
7680 }
7781 }
7882
79- public function saveAll ()
83+ public function saveAll ($ skippedRelations = [] )
8084 {
8185 /* @var $this ActiveRecord */
8286 $ db = $ this ->getDb ();
@@ -87,13 +91,18 @@ public function saveAll()
8791 $ error = false ;
8892 if (!empty ($ this ->relatedRecords )) {
8993 foreach ($ this ->relatedRecords as $ name => $ records ) {
94+
95+ if (in_array ($ name ,$ skippedRelations ))
96+ continue ;
97+
9098 if (!empty ($ records )) {
9199 $ isHasMany = is_array ($ records );
92100 $ AQ = $ this ->getRelation ($ name );
93101 $ link = $ AQ ->link ;
94102 $ notDeletedPK = [];
95103 $ relPKAttr = $ records [0 ]->primaryKey ();
96104 $ isManyMany = (count ($ relPKAttr ) > 1 );
105+
97106 if ($ isHasMany ) {
98107 /* @var $relModel ActiveRecord */
99108 $ i = 0 ;
@@ -176,6 +185,9 @@ public function saveAll()
176185 if (!$ isNewRecord ) {
177186 $ relData = $ this ->getRelationData ();
178187 foreach ($ relData as $ rel ) {
188+ if (in_array ($ rel ['name ' ], $ skippedRelations ))
189+ continue ;
190+
179191 /* @var $relModel ActiveRecord */
180192 if (empty ($ rel ['via ' ])){
181193 $ relModel = new $ rel ['modelClass ' ];
0 commit comments