ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilADTMultiEnumFormBridge.php
Go to the documentation of this file.
1 <?php
2 
3 require_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 ?>
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.
This class represents an option in a checkbox group.
ADT form bridge base class.
isActiveForSubItems($a_parent_option=null)
ADT base class.
Definition: class.ilADT.php:11
addBasicFieldProperties(ilFormPropertyGUI $a_field, ilADTDefinition $a_def)
Helper method to handle generic properties like setRequired(), setInfo()
if(!is_array($argv)) $options
This class represents a property in a property form.
getElementId()
Get element id.
global $lng
Definition: privfeed.php:40