From 3dd99f8a111097e682144cdc5dd128796e235cb2 Mon Sep 17 00:00:00 2001 From: Thierry Bugier Date: Fri, 7 Jun 2024 09:34:16 +0200 Subject: [PATCH] fix(fieldsfield): required property update on UI --- ajax/question_design.php | 2 ++ inc/field/fieldsfield.class.php | 2 +- templates/field/fieldsfield.html.twig | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ajax/question_design.php b/ajax/question_design.php index 393d90bbd..d94858638 100644 --- a/ajax/question_design.php +++ b/ajax/question_design.php @@ -69,5 +69,7 @@ $question->fields['fieldtype'] = ''; if ($field !== null) { $question->fields['fieldtype'] = $_REQUEST['fieldtype']; + $question->fields['_blocks_field'] = $_REQUEST['blocks_field'] ?? null; + $question->fields['_dropdown_fields_field'] = $_REQUEST['dropdown_fields_field'] ?? null; } $question->showForm($question->getID()); diff --git a/inc/field/fieldsfield.class.php b/inc/field/fieldsfield.class.php index dd3d2ed35..d66411b21 100644 --- a/inc/field/fieldsfield.class.php +++ b/inc/field/fieldsfield.class.php @@ -63,7 +63,7 @@ class FieldsField extends PluginFormcreatorAbstractField public function getField(): ?PluginFieldsField { if ($this->field === null && isset($this->question->fields['values'])) { $decodedValues = json_decode($this->question->fields['values'], JSON_OBJECT_AS_ARRAY); - $field_name = $decodedValues['dropdown_fields_field'] ?? ''; + $field_name = $decodedValues['dropdown_fields_field'] ?? ($this->question->fields['_field_name'] ?? ''); $fieldObj = new PluginFieldsField(); if ($fieldObj->getFromDBByCrit(['name' => $field_name])) { $this->field = $fieldObj; diff --git a/templates/field/fieldsfield.html.twig b/templates/field/fieldsfield.html.twig index e333cba0a..e94774fb1 100644 --- a/templates/field/fieldsfield.html.twig +++ b/templates/field/fieldsfield.html.twig @@ -59,6 +59,7 @@ item.fields['_field_list'], item.fields['_drodpdown_field_label'], { + on_change: 'plugin_formcreator.changeQuestionType(this)', display_emptychoice: true, label_class: 'col-xxl-4', input_class: 'col-xxl-8',