ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilADTFloatFormBridge.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 ilADTFloat);
10  }
11 
12  public function addToForm()
13  {
14  $def = $this->getADT()->getCopyOfDefinition();
15 
16  $number = new ilNumberInputGUI($this->getTitle(), $this->getElementId());
17  $number->setSize(10);
18  $number->setDecimals($def->getDecimals());
19 
20  $this->addBasicFieldProperties($number, $def);
21 
22  $min = $def->getMin();
23  if ($min !== null) {
24  $number->setMinValue($min);
25  }
26 
27  $max = $def->getMax();
28  if ($max !== null) {
29  $number->setMaxValue($max);
30 
31  $length = strlen($max) + $def->getDecimals() + 1;
32  $number->setSize($length);
33  $number->setMaxLength($length);
34  }
35 
36  $suffix = $def->getSuffix();
37  if ($suffix !== null) {
38  $number->setSuffix($suffix);
39  }
40 
41  $number->setValue($this->getADT()->getNumber());
42 
43  $this->addToParentElement($number);
44  }
45 
46  public function importFromPost()
47  {
48  // ilPropertyFormGUI::checkInput() is pre-requisite
49  $this->getADT()->setNumber($this->getForm()->getInput($this->getElementId()));
50 
51  $field = $this->getForm()->getItemByPostvar($this->getElementId());
52  $field->setValue($this->getADT()->getNumber());
53  }
54 }
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.
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.
getElementId()
Get element id.
$def
Definition: croninfo.php:21