ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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)
 Constructor. More...
 
 getADT ()
 Get ADT. More...
 
 setForm (ilPropertyFormGUI $a_form)
 Set form. More...
 
 getForm ()
 Get form. More...
 
 setElementId ($a_value)
 Set element id (aka form field) More...
 
 getElementId ()
 Get element id. More...
 
 setTitle ($a_value)
 Set title (aka form field caption) More...
 
 getTitle ()
 Get title. More...
 
 setInfo ($a_value)
 Set info (aka form field info text) More...
 
 getInfo ()
 Get info. More...
 
 setParentElement ($a_value)
 Set parent element. More...
 
 getParentElement ()
 Get parent element. More...
 
 setDisabled ($a_value)
 Set disabled. More...
 
 isDisabled ()
 Get disabled. More...
 
 setRequired ($a_value)
 Set required. More...
 
 isRequired ()
 Get required. More...
 
 addToForm ()
 Add ADT-specific fields to form. More...
 
 addJS (ilTemplate $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 ()
 Validate ADT and parse error codes. More...
 
 setExternalErrors ($a_errors)
 

Protected Member Functions

 isValidADT (ilADT $a_adt)
 
 isActiveForSubItems ($a_parent_option=null)
 
- Protected Member Functions inherited from ilADTFormBridge
 isValidADT (ilADT $a_adt)
 Check if given ADT is valid. More...
 
 setADT (ilADT $a_adt)
 Set ADT. More...
 
 addBasicFieldProperties (ilFormPropertyGUI $a_field, ilADTDefinition $a_def)
 Helper method to handle generic properties like setRequired(), setInfo() More...
 
 findParentElementInForm ()
 Try to find parent element in form (could be option) More...
 
 addToParentElement (ilFormPropertyGUI $a_field)
 Add form field to parent element. More...
 
 isActiveForSubItems ($a_parent_option=null)
 Check if element is currently active for subitem(s) More...
 

Protected Attributes

 $force_radio
 
 $option_infos = []
 
 $auto_sort = true
 
- Protected Attributes inherited from ilADTFormBridge
 $adt
 
 $form
 
 $id
 
 $title
 
 $info
 
 $parent_element
 
 $required
 
 $disabled
 

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 $def, $DIC, $force_radio, $lng, $options, ilADTFormBridge\addBasicFieldProperties(), ilADTFormBridge\addToParentElement(), array, ilADTFormBridge\getADT(), ilADTFormBridge\getElementId(), ilADTFormBridge\getTitle(), and ilADTFormBridge\isRequired().

30  {
31  global $DIC;
32 
33  $lng = $DIC['lng'];
34 
35  $def = $this->getADT()->getCopyOfDefinition();
36  $selection = $this->getADT()->getSelection();
37 
38  $options = $def->getOptions();
39 
40  if ((bool) $this->auto_sort) {
41  asort($options);
42  }
43 
44  if (!$this->isRequired()) {
45  $options = array("" => "-") + $options;
46  } elseif ($this->getADT()->isNull()) {
47  $options = array("" => $lng->txt("please_select")) + $options;
48  }
49 
50  if (!(bool) $this->force_radio) {
51  $select = new ilSelectInputGUI($this->getTitle(), $this->getElementId());
52 
53  $select->setOptions($options);
54  } else {
55  $select = new ilRadioGroupInputGUI($this->getTitle(), $this->getElementId());
56 
57  foreach ($options as $value => $caption) {
58  $option = new ilRadioOption($caption, $value);
59  if (is_array($this->option_infos) && array_key_exists($value, $this->option_infos)) {
60  $option->setInfo($this->option_infos[$value]);
61  }
62  $select->addOption($option);
63  }
64  }
65 
66  $this->addBasicFieldProperties($select, $def);
67 
68  $select->setValue($selection);
69 
70  $this->addToParentElement($select);
71  }
This class represents an option in a radio group.
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.
This class represents a selection list property in a property form.
global $DIC
Definition: saml.php:7
isRequired()
Get required.
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.
Create styles array
The data for the language used.
getElementId()
Get element id.
global $lng
Definition: privfeed.php:17
$def
Definition: croninfo.php:21
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
+ 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 = $a_info;
26  }
27  }

◆ importFromPost()

ilADTEnumFormBridge::importFromPost ( )

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

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

74  {
75  // ilPropertyFormGUI::checkInput() is pre-requisite
76  $this->getADT()->setSelection($this->getForm()->getInput($this->getElementId()));
77 
78  $field = $this->getForm()->getItemByPostvar($this->getElementId());
79  $field->setValue($this->getADT()->getSelection());
80  }
getElementId()
Get element id.
+ Here is the call graph for this function:

◆ isActiveForSubItems()

ilADTEnumFormBridge::isActiveForSubItems (   $a_parent_option = null)
protected

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

References ilADTFormBridge\getADT().

83  {
84  return ($this->getADT()->getSelection() == $a_parent_option);
85  }
+ Here is the call graph for this function:

◆ isValidADT()

ilADTEnumFormBridge::isValidADT ( ilADT  $a_adt)
protected

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

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

ilADTEnumFormBridge::$auto_sort = true
protected

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

◆ $force_radio

ilADTEnumFormBridge::$force_radio
protected

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

Referenced by addToForm().

◆ $option_infos

ilADTEnumFormBridge::$option_infos = []
protected

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


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