ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilADTDateFormBridge.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25{
26 protected bool $invalid_input = false;
27
28 protected function isValidADT(ilADT $a_adt): bool
29 {
30 return ($a_adt instanceof ilADTDate);
31 }
32
33 protected function addToElementId($a_add): string
34 {
35 return $this->getElementId() . "[" . $a_add . "]";
36 }
37
38 public function addToForm(): void
39 {
40 $adt_date = $this->getADT()->getDate();
41
42 $date = new ilDateTimeInputGUI($this->getTitle(), $this->getElementId());
43 $date->setShowTime(false);
44
45 $this->addBasicFieldProperties($date, $this->getADT()->getCopyOfDefinition());
46
47 $date->setDate($adt_date);
48
49 $this->addToParentElement($date);
50 }
51
52 public function importFromPost(): void
53 {
54 $field = $this->getForm()->getItemByPostVar($this->getElementId());
55
56 // because of ilDate the ADT can only have valid dates
57 if (!$field->hasInvalidInput()) {
58 // ilPropertyFormGUI::checkInput() is pre-requisite
59 $this->getADT()->setDate($field->getDate());
60
61 $field->setDate($this->getADT()->getDate());
62 } else {
63 $this->invalid_input = true;
64 }
65 }
66
67 public function validate(): bool
68 {
69 // :TODO: error handling is done by ilDateTimeInputGUI
71 }
72}
Class ilADTDateFormBridge.
addToForm()
Add ADT-specific fields to form.
importFromPost()
Import values from form request POST data.
ADT form bridge base class.
addBasicFieldProperties(ilFormPropertyGUI $a_field, ilADTDefinition $a_def)
Helper method to handle generic properties like setRequired(), setInfo()
addToParentElement(ilFormPropertyGUI $a_field)
ADT base class.
Definition: class.ilADT.php:26
This class represents a date/time property in a property form.