ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilADTBooleanFormBridge.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 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 }
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.
ADT form bridge base class.
This class represents a checkbox property in a property form.
ADT base class.
Definition: class.ilADT.php:11
addBasicFieldProperties(ilFormPropertyGUI $a_field, ilADTDefinition $a_def)
Helper method to handle generic properties like setRequired(), setInfo()
getElementId()
Get element id.
isActiveForSubItems($a_parent_option=null)