ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilADTIntegerFormBridge.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 ilADTInteger);
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 
19  $this->addBasicFieldProperties($number, $def);
20 
21  $min = $def->getMin();
22  if ($min !== null) {
23  $number->setMinValue($min);
24  }
25 
26  $max = $def->getMax();
27  if ($max !== null) {
28  $number->setMaxValue($max);
29 
30  $length = strlen($max);
31  $number->setSize($length);
32  $number->setMaxLength($length);
33  }
34 
35  $suffix = $def->getSuffix();
36  if ($suffix !== null) {
37  $number->setSuffix($suffix);
38  }
39 
40  $number->setValue($this->getADT()->getNumber());
41 
42  $this->addToParentElement($number);
43  }
44 
45  public function importFromPost()
46  {
47  // ilPropertyFormGUI::checkInput() is pre-requisite
48  $this->getADT()->setNumber($this->getForm()->getInput($this->getElementId()));
49 
50  $field = $this->getForm()->getItemByPostvar($this->getElementId());
51  $field->setValue($this->getADT()->getNumber());
52  }
53 }
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