ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilADTGroupFormBridge Class Reference
+ Inheritance diagram for ilADTGroupFormBridge:
+ Collaboration diagram for ilADTGroupFormBridge:

Public Member Functions

 getElements ()
 
 getElement ($a_name)
 
 addToForm ()
 
 addJS (ilTemplate $a_tpl)
 
 importFromPost ()
 
 validate ()
 
- 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)
 
 prepareElements ()
 
- 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

 $elements = []
 
- Protected Attributes inherited from ilADTFormBridge
 $adt
 
 $form
 
 $id
 
 $title
 
 $info
 
 $parent_element
 
 $required
 
 $disabled
 

Detailed Description

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

Member Function Documentation

◆ addJS()

ilADTGroupFormBridge::addJS ( ilTemplate  $a_tpl)

Definition at line 65 of file class.ilADTGroupFormBridge.php.

References prepareElements().

66  {
67  $this->prepareElements();
68  foreach ($this->elements as $element) {
69  $element->addJS($a_tpl);
70  }
71  }
+ Here is the call graph for this function:

◆ addToForm()

ilADTGroupFormBridge::addToForm ( )

Definition at line 46 of file class.ilADTGroupFormBridge.php.

References $section, ilADTFormBridge\getForm(), ilADTFormBridge\getInfo(), ilADTFormBridge\getTitle(), and prepareElements().

47  {
48  if ($this->getTitle()) {
50  $section->setTitle($this->getTitle());
51 
52  if ($this->getInfo()) {
53  $section->setInfo($this->getInfo());
54  }
55 
56  $this->getForm()->addItem($section);
57  }
58 
59  $this->prepareElements();
60  foreach ($this->elements as $element) {
61  $element->addToForm();
62  }
63  }
This class represents a section header in a property form.
$section
Definition: Utf8Test.php:83
+ Here is the call graph for this function:

◆ getElement()

ilADTGroupFormBridge::getElement (   $a_name)

Definition at line 38 of file class.ilADTGroupFormBridge.php.

References prepareElements().

Referenced by ilADTTestGUI\prepareFormElements().

39  {
40  $this->prepareElements();
41  if (array_key_exists($a_name, $this->elements)) {
42  return $this->elements[$a_name];
43  }
44  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getElements()

ilADTGroupFormBridge::getElements ( )

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

References $elements, and prepareElements().

Referenced by prepareElements(), ilADTTestGUI\prepareFormElements(), and validate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importFromPost()

ilADTGroupFormBridge::importFromPost ( )

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

References prepareElements().

74  {
75  $this->prepareElements();
76  foreach ($this->elements as $element) {
77  // parse parent element
78  $parent = $element->getParentElement();
79  if ($parent) {
80  if (is_array($parent)) {
81  $parent = $parent[0];
82  }
83  if (isset($adt_forms[$parent])) {
84  $parent = $adt_forms[$parent];
85  } else {
86  $parent = null;
87  }
88  }
89  if ($element->shouldBeImportedFromPost($parent)) {
90  $element->importFromPost();
91  }
92  }
93  }
+ Here is the call graph for this function:

◆ isValidADT()

ilADTGroupFormBridge::isValidADT ( ilADT  $a_adt)
protected

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

10  {
11  return ($a_adt instanceof ilADTGroup);
12  }

◆ prepareElements()

ilADTGroupFormBridge::prepareElements ( )
protected

Definition at line 14 of file class.ilADTGroupFormBridge.php.

References $factory, $name, ilADTFormBridge\getADT(), getElements(), ilADTFormBridge\getForm(), and ilADTFactory\getInstance().

Referenced by addJS(), addToForm(), getElement(), getElements(), and importFromPost().

15  {
16  if (sizeof($this->elements)) {
17  return;
18  }
19 
20  $this->elements = array();
22 
23  // convert ADTs to form bridges
24 
25  foreach ($this->getADT()->getElements() as $name => $element) {
26  $this->elements[$name] = $factory->getFormBridgeForInstance($element);
27  $this->elements[$name]->setForm($this->getForm());
28  $this->elements[$name]->setElementId($name);
29  }
30  }
$factory
Definition: metadata.php:43
static getInstance()
Get singleton.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ validate()

ilADTGroupFormBridge::validate ( )

Definition at line 95 of file class.ilADTGroupFormBridge.php.

References $DIC, $errors, $lng, $valid, ilADTFormBridge\getADT(), getElements(), and ilADTFormBridge\getForm().

96  {
97  global $DIC;
98 
99  $lng = $DIC['lng'];
100 
101  $valid = true;
102 
103  // ilADTFormBridge->isRequired() != ilADT->allowNull()
104  foreach ($this->getElements() as $element_id => $element) {
105  if ($element->isRequired() && $element->getADT()->isNull()) {
106  $field = $this->getForm()->getItemByPostvar($element_id);
107  $field->setAlert($lng->txt("msg_input_is_required"));
108  $valid = false;
109  }
110  // #17232 - date time input GUI special case
111  elseif (!$element->validate()) {
112  $valid = false;
113  }
114  }
115 
116  if (!$this->getADT()->isValid()) {
117  $tmp = array();
118 
119  // map errors to elements
120 
121  $mess = $this->getADT()->getValidationErrorsByElements();
122  foreach ($mess as $error_code => $element_id) {
123  $tmp[$element_id][] = $this->getADT()->translateErrorCode($error_code);
124  }
125 
126  foreach ($tmp as $element_id => $errors) {
127  $field = $this->getForm()->getItemByPostvar($element_id);
128  $field->setAlert(implode("<br />", $errors));
129  }
130 
131  $valid = false;
132  }
133 
134  return $valid;
135  }
global $DIC
Definition: saml.php:7
$valid
$lng
$errors
Definition: index.php:6
+ Here is the call graph for this function:

Field Documentation

◆ $elements

ilADTGroupFormBridge::$elements = []
protected

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

Referenced by getElements().


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