ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilADTIntegerFormBridge.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
22 {
23  protected function isValidADT(ilADT $a_adt): bool
24  {
25  return ($a_adt instanceof ilADTInteger);
26  }
27 
28  public function addToForm(): void
29  {
30  $def = $this->getADT()->getCopyOfDefinition();
31 
32  $number = new ilNumberInputGUI($this->getTitle(), $this->getElementId());
33  $number->setSize(10);
34 
35  $this->addBasicFieldProperties($number, $def);
36 
37  $min = $def->getMin();
38  if ($min !== null) {
39  $number->setMinValue($min);
40  }
41 
42  $max = $def->getMax();
43  if ($max !== null) {
44  $number->setMaxValue($max);
45  $length = strlen(strval($max));
46  $number->setSize($length);
47  $number->setMaxLength($length);
48  }
49 
50  $suffix = $def->getSuffix();
51  if ($suffix !== null) {
52  $number->setSuffix($suffix);
53  }
54  $number->setValue((string) $this->getADT()->getNumber());
55  $this->addToParentElement($number);
56  }
57 
58  public function importFromPost(): void
59  {
60  // ilPropertyFormGUI::checkInput() is pre-requisite
61  $input = $this->getForm()->getInput($this->getElementId());
62  if (isset($input)) {
63  $input = (int) $input;
64  }
65  $this->getADT()->setNumber($input);
66  $field = $this->getForm()->getItemByPostVar($this->getElementId());
67  $field->setValue((string) $this->getADT()->getNumber());
68  }
69 }
addToParentElement(ilFormPropertyGUI $a_field)
ADT form bridge base class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ADT base class.
Definition: class.ilADT.php:11
addBasicFieldProperties(ilFormPropertyGUI $a_field, ilADTDefinition $a_def)
Helper method to handle generic properties like setRequired(), setInfo()
This class represents a number property in a property form.