ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilDclSelectionFieldRepresentation.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 {
23  protected function buildFieldCreationInput(ilObjDataCollection $dcl, string $mode = 'create'): ilRadioOption
24  {
25  $opt = parent::buildFieldCreationInput($dcl, $mode);
26 
27  $selection_options = $this->buildOptionsInput();
28  $opt->addSubItem($selection_options);
29 
30  $selection_type = new ilRadioGroupInputGUI(
31  $this->lng->txt('dcl_selection_type'),
32  'prop_' . $this->field::PROP_SELECTION_TYPE
33  );
34  $selection_type->setRequired(true);
35 
36  $option_1 = new ilRadioOption(
39  );
40  $selection_type->addOption($option_1);
41 
42  $option_2 = new ilRadioOption(
45  );
46  $selection_type->addOption($option_2);
47 
48  $option_3 = new ilRadioOption(
51  );
52  $selection_type->addOption($option_3);
53 
54  $opt->addSubItem($selection_type);
55 
56  return $opt;
57  }
58 
59  public function getInputField(ilPropertyFormGUI $form, ?int $record_id = null): ilFormPropertyGUI
60  {
61  $options = [];
62  foreach (ilDclSelectionOption::getAllForField((int) $this->getField()->getId()) as $opt) {
63  $options[$opt->getOptId()] = $opt->getValue();
64  }
65  switch ($this->getField()->getProperty($this->field::PROP_SELECTION_TYPE)) {
67  $input = new ilMultiSelectInputGUI(
68  $this->getField()->getTitle(),
69  'field_' . $this->getField()->getId()
70  );
71  $input->setWidth(100);
72  $input->setWidthUnit('%');
73  $input->setHeight(32 * min(5, max(1, count($options))));
74 
75  $input->setOptions($options);
76  break;
78  $input = new ilSelectInputGUI($this->getField()->getTitle(), 'field_' . $this->getField()->getId());
79  $input->setOptions(["" => $this->lng->txt('dcl_please_select')] + $options);
80  break;
82  default:
83  $input = new ilRadioGroupInputGUI($this->getField()->getTitle(), 'field_' . $this->getField()->getId());
84  foreach ($options as $key => $opt) {
85  $input->addOption(new ilRadioOption($opt, (string) $key));
86  }
87  $input->setValue((string) array_key_first($options));
88  break;
89  }
90  $this->setupInputField($input, $this->getField());
91 
92  return $input;
93  }
94 
95  public function addFilterInputFieldToTable(ilTable2GUI $table)
96  {
97  $input = $table->addFilterItemByMetaType(
98  "filter_" . $this->getField()->getId(),
100  false,
101  $this->getField()->getId()
102  );
103 
104  $options = ilDclSelectionOption::getAllForField((int) $this->getField()->getId());
105  $array = ['' => $this->lng->txt('dcl_all_entries')];
106  foreach ($options as $opt) {
107  $array[$opt->getOptId()] = $opt->getValue();
108  }
109 
110  $array['none'] = $this->lng->txt('dcl_no_entry');
111 
112  $input->setOptions($array);
113 
114  $this->setupFilterInputField($input);
115 
116  return $this->getFilterInputFieldValue($input);
117  }
118 
119  abstract protected function buildOptionsInput(): ilDclGenericMultiInputGUI;
120 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
buildFieldCreationInput(ilObjDataCollection $dcl, string $mode='create')
This class represents a selection list property in a property form.
setupInputField(ilFormPropertyGUI $input, ilDclBaseFieldModel $field)
Sets basic settings on field-input.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addFilterItemByMetaType(string $id, int $type=self::FILTER_TEXT, bool $a_optional=false, string $caption="")
Add filter by standard type.
This class represents a property in a property form.
getInputField(ilPropertyFormGUI $form, ?int $record_id=null)
string $key
Consumer key/client ID value.
Definition: System.php:193
static getAllForField(int $field_id)
setupFilterInputField(?ilTableFilterItem $input)
Set basic settings for filter-input-gui.
setRequired(bool $a_required)