ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
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  $options = [
40  ];
41 
42  foreach ($options as $option) {
43  $selection_type->addOption(new ilRadioOption($this->lng->txt('dcl_' . $option), $option));
44  }
45 
46  $opt->addSubItem($selection_type);
47 
48  return $opt;
49  }
50 
51  public function getInputField(ilPropertyFormGUI $form, ?int $record_id = null): ilFormPropertyGUI
52  {
53  $options = [];
54  foreach (ilDclSelectionOption::getAllForField((int) $this->getField()->getId()) as $opt) {
55  $options[$opt->getOptId()] = $opt->getValue();
56  }
57  switch ($this->getField()->getProperty($this->field::PROP_SELECTION_TYPE)) {
59  $input = new ilMultiSelectInputGUI(
60  $this->getField()->getTitle(),
61  'field_' . $this->getField()->getId()
62  );
63  $input->setWidth(100);
64  $input->setWidthUnit('%');
65  $input->setHeight(32 * min(5, max(1, count($options))));
66 
67  $input->setOptions($options);
68  break;
70  $input = new ilSelectInputGUI($this->getField()->getTitle(), 'field_' . $this->getField()->getId());
71  $input->setOptions(["" => $this->lng->txt('dcl_please_select')] + $options);
72  break;
74  default:
75  $input = new ilRadioGroupInputGUI($this->getField()->getTitle(), 'field_' . $this->getField()->getId());
76  foreach ($options as $key => $opt) {
77  $input->addOption(new ilRadioOption($opt, (string) $key));
78  }
79  $input->setValue((string) array_key_first($options));
80  break;
81  }
82  $this->setupInputField($input, $this->getField());
83 
84  return $input;
85  }
86 
87  public function addFilterInputFieldToTable(ilTable2GUI $table)
88  {
89  $input = $table->addFilterItemByMetaType(
90  "filter_" . $this->getField()->getId(),
92  false,
93  $this->getField()->getId()
94  );
95 
96  $options = ilDclSelectionOption::getAllForField((int) $this->getField()->getId());
97  $array = ['' => $this->lng->txt('dcl_all_entries')];
98  foreach ($options as $opt) {
99  $array[$opt->getOptId()] = $opt->getValue();
100  }
101 
102  $array['none'] = $this->lng->txt('dcl_no_entry');
103 
104  $input->setOptions($array);
105 
106  $this->setupFilterInputField($input);
107 
108  return $this->getFilterInputFieldValue($input);
109  }
110 
111  abstract protected function buildOptionsInput(): ilDclGenericMultiInputGUI;
112 }
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)
static getAllForField(int $field_id)
setupFilterInputField(?ilTableFilterItem $input)
Set basic settings for filter-input-gui.
setRequired(bool $a_required)