ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilADTFloatFormBridge.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
22 {
23  protected function isValidADT(ilADT $a_adt): bool
24  {
25  return ($a_adt instanceof ilADTFloat);
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  $number->setDecimals($def->getDecimals());
35 
36  $this->addBasicFieldProperties($number, $def);
37 
38  $min = $def->getMin();
39  if ($min !== null) {
40  $number->setMinValue($min);
41  }
42 
43  $max = $def->getMax();
44  if ($max !== null) {
45  $number->setMaxValue($max);
46 
47  $length = strlen((string) $max) + $def->getDecimals() + 1;
48  $number->setSize($length);
49  $number->setMaxLength($length);
50  }
51  $suffix = $def->getSuffix();
52  if ($suffix !== null) {
53  $number->setSuffix($suffix);
54  }
55  $number->setValue((string) $this->getADT()->getNumber());
56  $this->addToParentElement($number);
57  }
58 
59  public function importFromPost(): void
60  {
61  // ilPropertyFormGUI::checkInput() is pre-requisite
62  $this->getADT()->setNumber($this->getForm()->getInput($this->getElementId()));
63  $field = $this->getForm()->getItemByPostVar($this->getElementId());
64  $field->setValue((string) $this->getADT()->getNumber());
65  }
66 }
addToParentElement(ilFormPropertyGUI $a_field)
ADT form bridge base class.
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.
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...