File tree 2 files changed +29
-0
lines changed
2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -772,6 +772,21 @@ public function duplicate(array $options = []) {
772
772
$ export [$ key ] = $ value ;
773
773
}
774
774
}
775
+
776
+ // Before importing the question, we need to give to the linker the questions
777
+ // used in the conditions of the question being duplicated
778
+ $ conditions = (new PluginFormcreatorCondition ())->find ([
779
+ 'itemtype ' => self ::getType (),
780
+ 'items_id ' => $ this ->getID ()
781
+ ]);
782
+ foreach ($ conditions as $ row ) {
783
+ $ question = PluginFormcreatorQuestion::getById ($ row ['plugin_formcreator_questions_id ' ]);
784
+ if ($ question === null || $ question === false ) {
785
+ continue ;
786
+ }
787
+ $ linker ->addObject ($ row ['plugin_formcreator_questions_id ' ], $ question );
788
+ }
789
+
775
790
$ newQuestionId = static ::import ($ linker , $ export , $ this ->fields [$ sectionFk ]);
776
791
777
792
if ($ newQuestionId === false ) {
Original file line number Diff line number Diff line change @@ -239,6 +239,20 @@ public function duplicate(array $options = []) {
239
239
) + 1 ;
240
240
$ newSectionId = static ::import ($ linker , $ export , $ this ->fields [$ formFk ]);
241
241
242
+ // Before importing the section, we need to give to the linker the questions
243
+ // used in the conditions of the section being duplicated
244
+ $ conditions = (new PluginFormcreatorCondition ())->find ([
245
+ 'itemtype ' => self ::getType (),
246
+ 'items_id ' => $ this ->getID ()
247
+ ]);
248
+ foreach ($ conditions as $ row ) {
249
+ $ question = PluginFormcreatorQuestion::getById ($ row ['plugin_formcreator_questions_id ' ]);
250
+ if ($ question === null || $ question === false ) {
251
+ continue ;
252
+ }
253
+ $ linker ->addObject ($ row ['plugin_formcreator_questions_id ' ], $ question );
254
+ }
255
+
242
256
if ($ newSectionId === false ) {
243
257
return false ;
244
258
}
You can’t perform that action at this time.
0 commit comments