@@ -146,6 +146,66 @@ public function __invoke(): void
146146 uksort ($ column_array , 'strnatcasecmp ' );
147147 }
148148
149+ $ foreignKeyRow = '' ;
150+ $ existrelForeign = array_key_exists ('foreign_keys_data ' , $ relationsForeign )
151+ ? $ relationsForeign ['foreign_keys_data ' ]
152+ : [];
153+ $ i = 0 ;
154+
155+ foreach ($ existrelForeign as $ key => $ oneKey ) {
156+ $ foreignDb = $ oneKey ['ref_db_name ' ] ?? $ GLOBALS ['db ' ];
157+ $ foreignTable = false ;
158+ if ($ foreignDb ) {
159+ $ foreignTable = $ oneKey ['ref_table_name ' ] ?? false ;
160+ $ tables = $ this ->relation ->getTables ($ foreignDb , $ storageEngine );
161+ } else {
162+ $ tables = $ this ->relation ->getTables ($ GLOBALS ['db ' ], $ storageEngine );
163+ }
164+
165+ $ uniqueColumns = [];
166+ if ($ foreignDb && $ foreignTable ) {
167+ $ tableObject = Table::get (
168+ $ foreignTable ,
169+ $ foreignDb
170+ );
171+ $ uniqueColumns = $ tableObject ->getUniqueColumns (false , false );
172+ }
173+
174+ $ foreignKeyRow .= $ this ->template ->render ('table/relation/foreign_key_row ' , [
175+ 'i ' => $ i ,
176+ 'one_key ' => $ oneKey ,
177+ 'column_array ' => $ column_array ,
178+ 'options_array ' => $ options ,
179+ 'tbl_storage_engine ' => $ storageEngine ,
180+ 'db ' => $ GLOBALS ['db ' ],
181+ 'table ' => $ GLOBALS ['table ' ],
182+ 'url_params ' => $ GLOBALS ['urlParams ' ],
183+ 'databases ' => $ GLOBALS ['dblist ' ]->databases ,
184+ 'foreign_db ' => $ foreignDb ,
185+ 'foreign_table ' => $ foreignTable ,
186+ 'unique_columns ' => $ uniqueColumns ,
187+ 'tables ' => $ tables ,
188+ ]);
189+ $ i ++;
190+ }
191+
192+ $ tables = $ this ->relation ->getTables ($ GLOBALS ['db ' ], $ storageEngine );
193+ $ foreignKeyRow .= $ this ->template ->render ('table/relation/foreign_key_row ' , [
194+ 'i ' => $ i ,
195+ 'one_key ' => [],
196+ 'column_array ' => $ column_array ,
197+ 'options_array ' => $ options ,
198+ 'tbl_storage_engine ' => $ storageEngine ,
199+ 'db ' => $ GLOBALS ['db ' ],
200+ 'table ' => $ GLOBALS ['table ' ],
201+ 'url_params ' => $ GLOBALS ['urlParams ' ],
202+ 'databases ' => $ GLOBALS ['dblist ' ]->databases ,
203+ 'foreign_db ' => false ,
204+ 'foreign_table ' => false ,
205+ 'unique_columns ' => [],
206+ 'tables ' => $ tables ,
207+ ]);
208+
149209 // common form
150210 $ engine = $ this ->dbi ->getTable ($ GLOBALS ['db ' ], $ GLOBALS ['table ' ])->getStorageEngine ();
151211 $ this ->render ('table/relation/common_form ' , [
@@ -155,9 +215,7 @@ public function __invoke(): void
155215 'relation_parameters ' => $ relationParameters ,
156216 'tbl_storage_engine ' => $ storageEngine ,
157217 'existrel ' => $ relations ,
158- 'existrel_foreign ' => array_key_exists ('foreign_keys_data ' , $ relationsForeign )
159- ? $ relationsForeign ['foreign_keys_data ' ]
160- : [],
218+ 'existrel_foreign ' => $ existrelForeign ,
161219 'options_array ' => $ options ,
162220 'column_array ' => $ column_array ,
163221 'column_hash_array ' => $ column_hash_array ,
@@ -168,6 +226,7 @@ public function __invoke(): void
168226 'default_sliders_state ' => $ GLOBALS ['cfg ' ]['InitialSlidersState ' ],
169227 'route ' => $ route ,
170228 'display_field ' => $ this ->relation ->getDisplayField ($ GLOBALS ['db ' ], $ GLOBALS ['table ' ]),
229+ 'foreign_key_row ' => $ foreignKeyRow ,
171230 ]);
172231 }
173232
0 commit comments