From 120cc5f52c67bb1365475f8abd48aad171b070be Mon Sep 17 00:00:00 2001 From: iszmais <45942348+iszmais@users.noreply.github.com> Date: Thu, 18 Jul 2024 17:10:03 +0200 Subject: [PATCH] Display onyl single types on field edit (#7830) --- .../Fields/class.ilDclFieldEditGUI.php | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/components/ILIAS/DataCollection/classes/Fields/class.ilDclFieldEditGUI.php b/components/ILIAS/DataCollection/classes/Fields/class.ilDclFieldEditGUI.php index 4fb0cf2f0569..8b1fe2d902aa 100755 --- a/components/ILIAS/DataCollection/classes/Fields/class.ilDclFieldEditGUI.php +++ b/components/ILIAS/DataCollection/classes/Fields/class.ilDclFieldEditGUI.php @@ -252,23 +252,19 @@ public function initForm(string $a_mode = "create"): void $edit_datatype = new ilRadioGroupInputGUI($lng->txt('dcl_datatype'), 'datatype'); - foreach (ilDclDatatype::getAllDatatype() as $datatype) { - $model = new ilDclBaseFieldModel(); - $model->setDatatypeId($datatype->getId()); - - if ($a_mode == 'edit' && $datatype->getId() == $this->field_obj->getDatatypeId()) { - $model = $this->field_obj; - } - - $field_representation = ilDclFieldFactory::getFieldRepresentationInstance($model); + if ($a_mode === 'edit') { + $field_representation = ilDclFieldFactory::getFieldRepresentationInstance($this->field_obj); $field_representation->addFieldCreationForm($edit_datatype, $this->getDataCollectionObject(), $a_mode); - } - $edit_datatype->setRequired(true); - - //you can't change type but we still need it in POST - if ($a_mode == "edit") { $edit_datatype->setDisabled(true); + } else { + foreach (ilDclDatatype::getAllDatatype() as $datatype) { + $model = new ilDclBaseFieldModel(); + $model->setDatatypeId($datatype->getId()); + $field_representation = ilDclFieldFactory::getFieldRepresentationInstance($model); + $field_representation->addFieldCreationForm($edit_datatype, $this->getDataCollectionObject()); + } } + $edit_datatype->setRequired(true); $this->form->addItem($edit_datatype); //Unique