Skip to content

Commit

Permalink
Display onyl single types on field edit (#7830)
Browse files Browse the repository at this point in the history
  • Loading branch information
iszmais authored Jul 18, 2024
1 parent 3982418 commit 120cc5f
Showing 1 changed file with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 120cc5f

Please sign in to comment.