@@ -946,7 +946,7 @@ public function prepareInputForUpdate($input) {
946946 }
947947
948948 $ plugin = new Plugin ();
949- if ($ plugin ->isInstalled ( ' tag ' ) && $ plugin -> isActivated ('tag ' )) {
949+ if ($ plugin ->isActivated ('tag ' )) {
950950 $ input ['tag_questions ' ] = (!empty ($ input ['_tag_questions ' ]))
951951 ? implode (', ' , $ input ['_tag_questions ' ])
952952 : '' ;
@@ -1214,7 +1214,6 @@ public function save(PluginFormcreatorFormAnswer $formanswer) {
12141214 // Add tag if presents
12151215 $ plugin = new Plugin ();
12161216 if ($ plugin ->isActivated ('tag ' )) {
1217-
12181217 $ tagObj = new PluginTagTagItem ();
12191218 $ tags = [];
12201219
@@ -1224,13 +1223,23 @@ public function save(PluginFormcreatorFormAnswer $formanswer) {
12241223 || $ this ->fields ['tag_type ' ] == 'questions_or_specific ' )
12251224 && (!empty ($ this ->fields ['tag_questions ' ]))) {
12261225
1227- $ query = "SELECT answer
1226+ $ query = "SELECT plugin_formcreator_questions_id, answer
12281227 FROM `glpi_plugin_formcreator_answers`
12291228 WHERE `plugin_formcreator_formanswers_id` = " . $ formanswer ->fields ['id ' ] . "
12301229 AND `plugin_formcreator_questions_id` IN ( " . $ this ->fields ['tag_questions ' ] . ") " ;
12311230 $ result = $ DB ->query ($ query );
12321231 while ($ line = $ DB ->fetch_array ($ result )) {
1233- $ tab = json_decode ($ line ['answer ' ]);
1232+ $ question = new PluginFormcreatorQuestion ();
1233+ $ question ->getFromDB ($ line ['plugin_formcreator_questions_id ' ]);
1234+ $ field = PluginFormcreatorFields::getFieldInstance (
1235+ $ question ->fields ['fieldtype ' ],
1236+ $ question
1237+ );
1238+ $ field ->deserializeValue ($ line ['answer ' ]);
1239+ $ tab = $ field ->getRawValue ();
1240+ if (is_integer ($ tab )) {
1241+ $ tab = [$ tab ];
1242+ }
12341243 if (is_array ($ tab )) {
12351244 $ tags = array_merge ($ tags , $ tab );
12361245 }
0 commit comments