ILIAS  release_8 Revision v8.25
class.ilADTBooleanFormBridge.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
6{
7 protected function isValidADT(ilADT $a_adt): bool
8 {
9 return ($a_adt instanceof ilADTBoolean);
10 }
11
12 public function addToForm(): void
13 {
14 $bool = new ilCheckboxInputGUI($this->getTitle(), $this->getElementId());
15 $bool->setValue('1');
16 $this->addBasicFieldProperties($bool, $this->getADT()->getCopyOfDefinition());
17 $bool->setRequired(false);
18 $bool->setChecked($this->getADT()->getStatus());
19 $this->addToParentElement($bool);
20 }
21
22 public function importFromPost(): void
23 {
24 // ilPropertyFormGUI::checkInput() is pre-requisite
25 $incoming = $this->getForm()->getInput($this->getElementId());
26
27 // unchecked == no incoming
28 $incoming = (bool) $incoming;
29
30 $this->getADT()->setStatus($incoming);
31
32 $field = $this->getForm()->getItemByPostVar($this->getElementId());
33 $field->setChecked($this->getADT()->getStatus());
34 }
35
36 public function validate(): bool
37 {
38 return true;
39 }
40
41 protected function isActiveForSubItems($a_parent_option = null): bool
42 {
43 return ($this->getADT()->getStatus() === true);
44 }
45}
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:12
This class represents a checkbox property in a property form.