File tree Expand file tree Collapse file tree
src/Package/System/events Expand file tree Collapse file tree Original file line number Diff line number Diff line change 9595 //for each row
9696 foreach ($ data ['rows ' ] as $ i => $ row ) {
9797 //prepare the data
98+ //NOTE: This removes the potential relational IDs
99+ // (we need to reinsert these later)
98100 $ data ['rows ' ][$ i ] = $ schema ->prepare ($ row , true );
99101 //dont allow to insert the primary id
100102 unset($ data ['rows ' ][$ i ][$ primary ]);
135137 foreach ($ schema ->getRelations () as $ table => $ relation ) {
136138 //set the 2nd primary
137139 $ primary2 = $ relation ['primary2 ' ];
140+ //look in stage for this ID because prepare() would have removed this
141+ $ id2 = $ request ->getStage ('rows ' , $ i , $ primary2 );
142+ //reinsert the relative id
143+ if (is_numeric ($ id2 )) {
144+ $ row [$ primary2 ] = $ id2 ;
145+ }
138146 //if id is invalid
139147 if (!isset ($ row [$ primary2 ]) || !is_numeric ($ row [$ primary2 ])) {
140148 //skip
155163 foreach ($ schema ->getReverseRelations () as $ table => $ relation ) {
156164 //set the 2nd primary
157165 $ primary2 = $ relation ['primary2 ' ];
166+ //look in stage for this ID because prepare() would have removed this
167+ $ id2 = $ request ->getStage ('rows ' , $ i , $ primary2 );
168+ //reinsert the relative id
169+ if (is_numeric ($ id2 )) {
170+ $ row [$ primary2 ] = $ id2 ;
171+ }
158172 //if id is invalid
159173 if (!isset ($ row [$ primary2 ]) || !is_numeric ($ row [$ primary2 ])) {
160174 //skip
You can’t perform that action at this time.
0 commit comments