From d40e6154a8080b92c6c69680425414e16fe4f742 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+studip@gmail.com> Date: Fri, 16 Feb 2024 13:41:26 +0000 Subject: [PATCH] fixes #3727 Closes #3727 Merge request studip/studip!2613 --- app/controllers/admin/plugin.php | 4 ++-- lib/classes/forms/I18n_textInput.php | 6 +++++- lib/classes/forms/I18n_textareaInput.php | 8 ++++++-- resources/assets/javascripts/bootstrap/forms.js | 1 + 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/controllers/admin/plugin.php b/app/controllers/admin/plugin.php index ef635175640..903c45ee1ae 100644 --- a/app/controllers/admin/plugin.php +++ b/app/controllers/admin/plugin.php @@ -591,10 +591,10 @@ class Admin_PluginController extends AuthenticatedController 'manifest_info_en' => [ 'label' => sprintf(_('Standardbeschreibung des Plugins (%s)'), _('Englisch')), 'type' => 'info', - 'value' => $this->metadata['descriptionlong_en'] ?? $this->metadata['description_en'], + 'value' => $this->metadata['descriptionlong_en'] ?? $this->metadata['description_en'] ?? null, 'if' => "STUDIPFORM_SELECTEDLANGUAGES.description === 'en_GB'" ], - 'decription_mode' => [ + 'description_mode' => [ 'label' => _('Modus der neuen Beschreibung'), 'type' => 'select', 'options' => [ diff --git a/lib/classes/forms/I18n_textInput.php b/lib/classes/forms/I18n_textInput.php index ae563b09427..4467c54d965 100644 --- a/lib/classes/forms/I18n_textInput.php +++ b/lib/classes/forms/I18n_textInput.php @@ -16,7 +16,11 @@ class I18n_textInput extends Input $value = $this->value; } else { $value = [\I18NString::getDefaultLanguage() => $this->value->original()]; - $value = json_encode(array_merge($value, $this->value->toArray())); + $value = array_merge($value, $this->value->toArray()); + $value = array_map(function ($item) { + return $item ?? ''; + }, $value); + $value = json_encode($value); } $template = $GLOBALS['template_factory']->open('forms/i18n_text_input'); $template->title = $this->title; diff --git a/lib/classes/forms/I18n_textareaInput.php b/lib/classes/forms/I18n_textareaInput.php index 44ba1f2d5e0..a544cb6d099 100644 --- a/lib/classes/forms/I18n_textareaInput.php +++ b/lib/classes/forms/I18n_textareaInput.php @@ -15,8 +15,12 @@ class I18n_textareaInput extends Input if (!is_object($this->value)) { $value = $this->value; } else { - $value = [\I18NString::getDefaultLanguage() => $this->value->original()]; - $value = json_encode(array_merge($value, $this->value->toArray())); + $value = [\I18NString::getDefaultLanguage() => $this->value->original() ?? '']; + $value = array_merge($value, $this->value->toArray()); + $value = array_map(function ($item) { + return $item ?? ''; + }, $value); + $value = json_encode($value); } $template = $GLOBALS['template_factory']->open('forms/i18n_textarea_input'); $template->title = $this->title; diff --git a/resources/assets/javascripts/bootstrap/forms.js b/resources/assets/javascripts/bootstrap/forms.js index e379d422f1f..c34a0c1bf94 100644 --- a/resources/assets/javascripts/bootstrap/forms.js +++ b/resources/assets/javascripts/bootstrap/forms.js @@ -258,6 +258,7 @@ STUDIP.ready(function () { params.STUDIPFORM_VALIDATED = false; params.STUDIPFORM_REDIRECTURL = f.dataset.url; params.STUDIPFORM_INPUTS_ORDER = []; + params.STUDIPFORM_SELECTEDLANGUAGES = {}; for (let i in JSON.parse(f.dataset.inputs)) { params.STUDIPFORM_INPUTS_ORDER.push(i); } -- GitLab