ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 ()
 Add ADT-specific fields to form. More...
 
 importFromPost ()
 Import values from form request POST data. More...
 
- 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)
 Check if element is currently active for subitem(s) More...
 
- 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 21 of file class.ilADTEnumFormBridge.php.

Member Function Documentation

◆ addToForm()

ilADTEnumFormBridge::addToForm ( )

Add ADT-specific fields to form.

Reimplemented from ilADTFormBridge.

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

45 : void
46 {
47 $def = $this->getADT()->getCopyOfDefinition();
48 $selection = $this->getADT()->getSelection();
49
50 $options = $def->getOptions();
51
52 if ($this->auto_sort) {
53 asort($options);
54 }
55
56 if (!$this->isRequired()) {
57 $options = array("" => "-") + $options;
58 } elseif ($this->getADT()->isNull()) {
59 $options = array("" => $this->lng->txt("please_select")) + $options;
60 }
61
62 if (!$this->force_radio) {
63 $select = new ilSelectInputGUI($this->getTitle(), $this->getElementId());
64
65 $select->setOptions($options);
66 } else {
67 $select = new ilRadioGroupInputGUI($this->getTitle(), $this->getElementId());
68
69 foreach ($options as $value => $caption) {
70 $option = new ilRadioOption($caption, $value);
71 if (is_array($this->option_infos) && array_key_exists($value, $this->option_infos)) {
72 $option->setInfo($this->option_infos[$value]);
73 }
74 $select->addOption($option);
75 }
76 }
77
78 $this->addBasicFieldProperties($select, $def);
79
80 $select->setValue($selection);
81
82 $this->addToParentElement($select);
83 }
addBasicFieldProperties(ilFormPropertyGUI $a_field, ilADTDefinition $a_def)
Helper method to handle generic properties like setRequired(), setInfo()
addToParentElement(ilFormPropertyGUI $a_field)
This class represents a property in a property form.
This class represents an option in a radio group.
This class represents a selection list property in a property form.

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

+ Here is the call graph for this function:

◆ forceRadio()

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

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

38 {
39 $this->force_radio = (bool) $a_value;
40 if ($this->force_radio) {
41 $this->option_infos = (array) $a_info;
42 }
43 }

◆ importFromPost()

ilADTEnumFormBridge::importFromPost ( )

Import values from form request POST data.

Reimplemented from ilADTFormBridge.

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

85 : void
86 {
87 // ilPropertyFormGUI::checkInput() is pre-requisite
88 $this->getADT()->setSelection($this->getForm()->getInput($this->getElementId()));
89
90 $field = $this->getForm()->getItemByPostVar($this->getElementId());
91 $field->setValue($this->getADT()->getSelection());
92 }

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

+ Here is the call graph for this function:

◆ isActiveForSubItems()

ilADTEnumFormBridge::isActiveForSubItems (   $a_parent_option = null)
protected

Check if element is currently active for subitem(s)

Parameters
mixed | null$a_parent_option
Returns
bool

Reimplemented from ilADTFormBridge.

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

94 : bool
95 {
96 return ($this->getADT()->getSelection() == $a_parent_option);
97 }

References ilADTFormBridge\getADT().

+ Here is the call graph for this function:

◆ isValidADT()

ilADTEnumFormBridge::isValidADT ( ilADT  $a_adt)
protected

Reimplemented from ilADTFormBridge.

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

27 : bool
28 {
29 return ($a_adt instanceof ilADTEnum);
30 }

◆ setAutoSort()

ilADTEnumFormBridge::setAutoSort (   $a_value)

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

33 {
34 $this->auto_sort = (bool) $a_value;
35 }

Field Documentation

◆ $auto_sort

bool ilADTEnumFormBridge::$auto_sort = true
protected

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

◆ $force_radio

bool ilADTEnumFormBridge::$force_radio = false
protected

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

◆ $option_infos

array ilADTEnumFormBridge::$option_infos = []
protected

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


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