ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilADTBooleanFormBridge.php
Go to the documentation of this file.
1<?php
2
3require_once "Services/ADT/classes/Bridges/class.ilADTFormBridge.php";
4
6{
7 protected function isValidADT(ilADT $a_adt)
8 {
9 return ($a_adt instanceof ilADTBoolean);
10 }
11
12 public function addToForm()
13 {
14 $bool = new ilCheckboxInputGUI($this->getTitle(), $this->getElementId());
15 $bool->setValue(1);
16
17 $this->addBasicFieldProperties($bool, $this->getADT()->getCopyOfDefinition());
18
19 // :TODO: required checkboxes do not make sense
20 $bool->setRequired(false);
21
22 $bool->setChecked($this->getADT()->getStatus());
23
24 $this->addToParentElement($bool);
25 }
26
27 public function importFromPost()
28 {
29 // ilPropertyFormGUI::checkInput() is pre-requisite
30 $incoming = $this->getForm()->getInput($this->getElementId());
31
32 // unchecked == no incoming
33 $incoming = (bool)$incoming;
34
35 $this->getADT()->setStatus($incoming);
36
37 $field = $this->getForm()->getItemByPostvar($this->getElementId());
38 $field->setChecked($this->getADT()->getStatus());
39 }
40
41 public function validate()
42 {
43 return true;
44 }
45
46 protected function isActiveForSubItems($a_parent_option = null)
47 {
48 return ($this->getADT()->getStatus() === true);
49 }
50}
51
52?>
isValidADT(ilADT $a_adt)
Check if given ADT is valid.
isActiveForSubItems($a_parent_option=null)
Check if element is currently active for subitem(s)
importFromPost()
Import values from form request POST data.
validate()
Validate ADT and parse error codes.
addToForm()
Add ADT-specific fields to form.
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.
ADT base class.
Definition: class.ilADT.php:12
This class represents a checkbox property in a property form.