ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  {
24  $number->setMinValue($min);
25  }
26 
27  $max = $def->getMax();
28  if($max !== null)
29  {
30  $number->setMaxValue($max);
31 
32  $length = strlen($max);
33  $number->setSize($length);
34  $number->setMaxLength($length);
35  }
36 
37  $suffix = $def->getSuffix();
38  if($suffix !== null)
39  {
40  $number->setSuffix($suffix);
41  }
42 
43  $number->setValue($this->getADT()->getNumber());
44 
45  $this->addToParentElement($number);
46  }
47 
48  public function importFromPost()
49  {
50  // ilPropertyFormGUI::checkInput() is pre-requisite
51  $this->getADT()->setNumber($this->getForm()->getInput($this->getElementId()));
52 
53  $field = $this->getForm()->getItemByPostvar($this->getElementId());
54  $field->setValue($this->getADT()->getNumber());
55  }
56 }
57 
58 ?>
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.