ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilADTDateFormBridge.php
Go to the documentation of this file.
1<?php
2
3require_once "Services/ADT/classes/Bridges/class.ilADTFormBridge.php";
4
6{
7 protected $invalid_input; // [bool]
8
9 protected function isValidADT(ilADT $a_adt)
10 {
11 return ($a_adt instanceof ilADTDate);
12 }
13
14 protected function addToElementId($a_add)
15 {
16 return $this->getElementId() . "[" . $a_add . "]";
17 }
18
19 public function addToForm()
20 {
21 $adt_date = $this->getADT()->getDate();
22
23 $date = new ilDateTimeInputGUI($this->getTitle(), $this->getElementId());
24 $date->setShowTime(false);
25
26 $this->addBasicFieldProperties($date, $this->getADT()->getCopyOfDefinition());
27
28 $date->setDate($adt_date);
29
30 $this->addToParentElement($date);
31 }
32
33 public function importFromPost()
34 {
35 $field = $this->getForm()->getItemByPostvar($this->getElementId());
36
37 // because of ilDate the ADT can only have valid dates
38 if (!$field->hasInvalidInput()) {
39 // ilPropertyFormGUI::checkInput() is pre-requisite
40 $this->getADT()->setDate($field->getDate());
41
42 $field->setDate($this->getADT()->getDate());
43 } else {
44 $this->invalid_input = true;
45 }
46 }
47
48 public function validate()
49 {
50 // :TODO: error handling is done by ilDateTimeInputGUI
51 return !(bool) $this->invalid_input;
52 }
53}
An exception for terminatinating execution or to throw for unit testing.
addToForm()
Add ADT-specific fields to form.
isValidADT(ilADT $a_adt)
Check if given ADT is valid.
importFromPost()
Import values from form request POST data.
validate()
Validate ADT and parse error codes.
ADT form bridge base class.
addBasicFieldProperties(ilFormPropertyGUI $a_field, ilADTDefinition $a_def)
Helper method to handle generic properties like setRequired(), setInfo()
getElementId()
Get element id.
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.
ADT base class.
Definition: class.ilADT.php:12
This class represents a date/time property in a property form.