File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 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 = []) {
772772 $ export [$ key ] = $ value ;
773773 }
774774 }
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+
775790 $ newQuestionId = static ::import ($ linker , $ export , $ this ->fields [$ sectionFk ]);
776791
777792 if ($ newQuestionId === false ) {
Original file line number Diff line number Diff line change @@ -239,6 +239,20 @@ public function duplicate(array $options = []) {
239239 ) + 1 ;
240240 $ newSectionId = static ::import ($ linker , $ export , $ this ->fields [$ formFk ]);
241241
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+
242256 if ($ newSectionId === false ) {
243257 return false ;
244258 }
You can’t perform that action at this time.
0 commit comments