ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilADTBooleanFormBridge.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 protected function isValidADT(ilADT $a_adt): bool
24 {
25 return ($a_adt instanceof ilADTBoolean);
26 }
27
28 public function addToForm(): void
29 {
30 $bool = new ilCheckboxInputGUI($this->getTitle(), $this->getElementId());
31 $bool->setValue('1');
32 $this->addBasicFieldProperties($bool, $this->getADT()->getCopyOfDefinition());
33 $bool->setRequired(false);
34 $bool->setChecked($this->getADT()->getStatus());
35 $this->addToParentElement($bool);
36 }
37
38 public function importFromPost(): void
39 {
40 // ilPropertyFormGUI::checkInput() is pre-requisite
41 $incoming = $this->getForm()->getInput($this->getElementId());
42
43 // unchecked == no incoming
44 $incoming = (bool) $incoming;
45
46 $this->getADT()->setStatus($incoming);
47
48 $field = $this->getForm()->getItemByPostVar($this->getElementId());
49 $field->setChecked($this->getADT()->getStatus());
50 }
51
52 public function validate(): bool
53 {
54 return true;
55 }
56
57 protected function isActiveForSubItems($a_parent_option = null): bool
58 {
59 return ($this->getADT()->getStatus() === true);
60 }
61}
isActiveForSubItems($a_parent_option=null)
Check if element is currently active for subitem(s)
importFromPost()
Import values from form request POST data.
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()
addToParentElement(ilFormPropertyGUI $a_field)
ADT base class.
Definition: class.ilADT.php:26
This class represents a checkbox property in a property form.