ILIAS  release_8 Revision v8.23
ilADTEnumFormBridge Class Reference
+ Inheritance diagram for ilADTEnumFormBridge:
+ Collaboration diagram for ilADTEnumFormBridge:

Public Member Functions

 setAutoSort ($a_value)
 
 forceRadio ($a_value, array $a_info=null)
 
 addToForm ()
 
 importFromPost ()
 
- Public Member Functions inherited from ilADTFormBridge
 __construct (ilADT $a_adt)
 
 getADT ()
 
 setForm (ilPropertyFormGUI $a_form)
 
 getForm ()
 
 setElementId (string $a_value)
 Set element id (aka form field) More...
 
 getElementId ()
 
 setTitle (string $a_value)
 
 getTitle ()
 
 setInfo (string $a_value)
 
 getInfo ()
 
 setParentElement ($a_value)
 
 getParentElement ()
 Get parent element. More...
 
 setDisabled (bool $a_value)
 
 isDisabled ()
 
 setRequired (bool $a_value)
 
 isRequired ()
 
 addToForm ()
 Add ADT-specific fields to form. More...
 
 addJS (ilGlobalTemplateInterface $a_tpl)
 Add ADT-specific JS-files to template. More...
 
 shouldBeImportedFromPost (ilADTFormBridge $a_parent_adt=null)
 Check if incoming values should be imported at all. More...
 
 importFromPost ()
 Import values from form request POST data. More...
 
 validate ()
 
 setExternalErrors (array $a_errors)
 

Protected Member Functions

 isValidADT (ilADT $a_adt)
 
 isActiveForSubItems ($a_parent_option=null)
 
- Protected Member Functions inherited from ilADTFormBridge
 isValidADT (ilADT $a_adt)
 
 setADT (ilADT $a_adt)
 
 addBasicFieldProperties (ilFormPropertyGUI $a_field, ilADTDefinition $a_def)
 Helper method to handle generic properties like setRequired(), setInfo() More...
 
 findParentElementInForm ()
 
 addToParentElement (ilFormPropertyGUI $a_field)
 
 isActiveForSubItems ($a_parent_option=null)
 Check if element is currently active for subitem(s) More...
 

Protected Attributes

bool $force_radio = false
 
array $option_infos = []
 
bool $auto_sort = true
 
- Protected Attributes inherited from ilADTFormBridge
ilADT $adt
 
ilPropertyFormGUI $form
 
 $parent
 
string $id = null
 
string $title = ''
 
string $info = ''
 
 $parent_element
 
bool $required = false
 
bool $disabled = false
 
ilLanguage $lng
 

Detailed Description

Definition at line 5 of file class.ilADTEnumFormBridge.php.

Member Function Documentation

◆ addToForm()

ilADTEnumFormBridge::addToForm ( )

Definition at line 29 of file class.ilADTEnumFormBridge.php.

References ilADTFormBridge\addBasicFieldProperties(), ilADTFormBridge\addToParentElement(), ilADTFormBridge\getADT(), ilADTFormBridge\getElementId(), ilADTFormBridge\getTitle(), ilADTFormBridge\isRequired(), and ILIAS\Repository\lng().

29  : void
30  {
31  $def = $this->getADT()->getCopyOfDefinition();
32  $selection = $this->getADT()->getSelection();
33 
34  $options = $def->getOptions();
35 
36  if ($this->auto_sort) {
37  asort($options);
38  }
39 
40  if (!$this->isRequired()) {
41  $options = array("" => "-") + $options;
42  } elseif ($this->getADT()->isNull()) {
43  $options = array("" => $this->lng->txt("please_select")) + $options;
44  }
45 
46  if (!$this->force_radio) {
47  $select = new ilSelectInputGUI($this->getTitle(), $this->getElementId());
48 
49  $select->setOptions($options);
50  } else {
51  $select = new ilRadioGroupInputGUI($this->getTitle(), $this->getElementId());
52 
53  foreach ($options as $value => $caption) {
54  $option = new ilRadioOption($caption, $value);
55  if (is_array($this->option_infos) && array_key_exists($value, $this->option_infos)) {
56  $option->setInfo($this->option_infos[$value]);
57  }
58  $select->addOption($option);
59  }
60  }
61 
62  $this->addBasicFieldProperties($select, $def);
63 
64  $select->setValue($selection);
65 
66  $this->addToParentElement($select);
67  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addToParentElement(ilFormPropertyGUI $a_field)
addBasicFieldProperties(ilFormPropertyGUI $a_field, ilADTDefinition $a_def)
Helper method to handle generic properties like setRequired(), setInfo()
This class represents a property in a property form.
+ Here is the call graph for this function:

◆ forceRadio()

ilADTEnumFormBridge::forceRadio (   $a_value,
array  $a_info = null 
)

Definition at line 21 of file class.ilADTEnumFormBridge.php.

22  {
23  $this->force_radio = (bool) $a_value;
24  if ($this->force_radio) {
25  $this->option_infos = (array) $a_info;
26  }
27  }

◆ importFromPost()

ilADTEnumFormBridge::importFromPost ( )

Definition at line 69 of file class.ilADTEnumFormBridge.php.

References ilADTFormBridge\getADT(), ilADTFormBridge\getElementId(), and ilADTFormBridge\getForm().

69  : void
70  {
71  // ilPropertyFormGUI::checkInput() is pre-requisite
72  $this->getADT()->setSelection($this->getForm()->getInput($this->getElementId()));
73 
74  $field = $this->getForm()->getItemByPostVar($this->getElementId());
75  $field->setValue($this->getADT()->getSelection());
76  }
+ Here is the call graph for this function:

◆ isActiveForSubItems()

ilADTEnumFormBridge::isActiveForSubItems (   $a_parent_option = null)
protected

Definition at line 78 of file class.ilADTEnumFormBridge.php.

References ilADTFormBridge\getADT().

78  : bool
79  {
80  return ($this->getADT()->getSelection() == $a_parent_option);
81  }
+ Here is the call graph for this function:

◆ isValidADT()

ilADTEnumFormBridge::isValidADT ( ilADT  $a_adt)
protected

Definition at line 11 of file class.ilADTEnumFormBridge.php.

11  : bool
12  {
13  return ($a_adt instanceof ilADTEnum);
14  }

◆ setAutoSort()

ilADTEnumFormBridge::setAutoSort (   $a_value)

Definition at line 16 of file class.ilADTEnumFormBridge.php.

17  {
18  $this->auto_sort = (bool) $a_value;
19  }

Field Documentation

◆ $auto_sort

bool ilADTEnumFormBridge::$auto_sort = true
protected

Definition at line 9 of file class.ilADTEnumFormBridge.php.

◆ $force_radio

bool ilADTEnumFormBridge::$force_radio = false
protected

Definition at line 7 of file class.ilADTEnumFormBridge.php.

◆ $option_infos

array ilADTEnumFormBridge::$option_infos = []
protected

Definition at line 8 of file class.ilADTEnumFormBridge.php.


The documentation for this class was generated from the following file: