diff --git a/inc/abstractfield.class.php b/inc/abstractfield.class.php index 12f1bd2d4..253a3e581 100644 --- a/inc/abstractfield.class.php +++ b/inc/abstractfield.class.php @@ -184,6 +184,11 @@ public function getEmptyParameters(): array { return []; } + /** + * Undocumented function + * + * @return PluginFormcreatorAbstractQuestionParameter[] + */ public final function getParameters(): array { $parameters = $this->getEmptyParameters(); foreach ($parameters as $fieldname => $parameter) { diff --git a/inc/question.class.php b/inc/question.class.php index 634a82d1b..a783f539e 100644 --- a/inc/question.class.php +++ b/inc/question.class.php @@ -961,7 +961,17 @@ public static function import(PluginFormcreatorLinker $linker, array $input = [] if (isset($input['_parameters'])) { $parameters = $field->getParameters(); foreach ($parameters as $fieldName => $parameter) { - $parameter::import($linker, $input['_parameters'][$input['fieldtype']][$fieldName], $itemId); + if (is_array($input['_parameters'][$input['fieldtype']][$fieldName])) { + /** @var PluginFormcreatorExportableInterface $parameter */ + $parameter::import($linker, $input['_parameters'][$input['fieldtype']][$fieldName], $itemId); + } else { + // Import data incomplete, parameter not defined + // Adding an empty parameter (assuming the question is actually added or updated in DB) + $parameterInput = $parameter->fields; + $parameterInput['plugin_formcreator_questions_id'] = $itemId; + unset($parameterInput['id']); + $parameter->add($parameterInput); + } } }