ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilADTMultiEnumFormBridge.php
Go to the documentation of this file.
1<?php
2
3require_once "Services/ADT/classes/Bridges/class.ilADTFormBridge.php";
4
6{
7 protected $option_infos; // [array]
8
9 protected function isValidADT(ilADT $a_adt)
10 {
11 return ($a_adt instanceof ilADTMultiEnum);
12 }
13
14 public function setOptionInfos(array $a_info = null)
15 {
16 $this->option_infos = $a_info;
17 }
18
19 public function addToForm()
20 {
21 global $lng;
22
23 $def = $this->getADT()->getCopyOfDefinition();
24
25 $options = $def->getOptions();
26 // asort($options); // ?
27
28 $cbox = new ilCheckboxGroupInputGUI($this->getTitle(), $this->getElementId());
29
30 foreach($options as $value => $caption)
31 {
32 $option = new ilCheckboxOption($caption, $value);
33 if(is_array($this->option_infos) && array_key_exists($value, $this->option_infos))
34 {
35 $option->setInfo($this->option_infos[$value]);
36 }
37 $cbox->addOption($option);
38 }
39
40 $this->addBasicFieldProperties($cbox, $def);
41
42 $cbox->setValue($this->getADT()->getSelections());
43
44 $this->addToParentElement($cbox);
45 }
46
47 public function importFromPost()
48 {
49 // ilPropertyFormGUI::checkInput() is pre-requisite
50 $this->getADT()->setSelections($this->getForm()->getInput($this->getElementId()));
51
52 $field = $this->getForm()->getItemByPostvar($this->getElementId());
53 $field->setValue($this->getADT()->getSelections());
54 }
55
56 protected function isActiveForSubItems($a_parent_option = null)
57 {
58 $current = $this->getADT()->getSelections();
59 return (is_array($current) && in_array($a_parent_option, $current));
60 }
61}
62
63?>
ADT form bridge base class.
addBasicFieldProperties(ilFormPropertyGUI $a_field, ilADTDefinition $a_def)
Helper method to handle generic properties like setRequired(), setInfo()
getElementId()
Get element id.
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.
isValidADT(ilADT $a_adt)
Check if given ADT is valid.
importFromPost()
Import values from form request POST data.
isActiveForSubItems($a_parent_option=null)
Check if element is currently active for subitem(s)
addToForm()
Add ADT-specific fields to form.
ADT base class.
Definition: class.ilADT.php:12
This class represents a property in a property form.
This class represents an option in a checkbox group.
global $lng
Definition: privfeed.php:40
if(!is_array($argv)) $options