From 177ee3d6d61f67cebe1213f559abadd8f7b94380 Mon Sep 17 00:00:00 2001 From: Robert Kaiser Date: Sun, 23 Jun 2024 22:24:43 +0200 Subject: [PATCH] add code for datetime-local input elements --- classes/document.php-class | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/classes/document.php-class b/classes/document.php-class index c2f0fcf..c48415f 100755 --- a/classes/document.php-class +++ b/classes/document.php-class @@ -89,6 +89,10 @@ class ExtendedDocument extends DOMDocument { // appends an ExtendedDocument::createElementInputTime() as a child of this document (see there for params) // returns the new child // + // public function appendInputDateTime($name, [$id], [$min], [$max], [$value]) + // appends an ExtendedDocument::createElementInputDateTime() as a child of this document (see there for params) + // returns the new child + // // public function appendInputColor($name, [$id], [$value]) // appends an ExtendedDocument::createElementInputColor() as a child of this document (see there for params) // returns the new child @@ -226,6 +230,10 @@ class ExtendedDocument extends DOMDocument { // returns an ExtendedElement that is an HTML of type 'time' with the given name, // and optionally id, min, max, and value // + // public function createElementInputDateTime($name, [$id], [$min], [$max], [$value]) + // returns an ExtendedElement that is an HTML of type 'datetime-local' with the given name, + // and optionally id, min, max, and value + // // public function createElementInputColor($name, [$id], [$value]) // returns an ExtendedElement that is an HTML of type 'color' with the given name, // and optionally id and value @@ -383,6 +391,9 @@ class ExtendedDocument extends DOMDocument { public function appendInputTime($name, $id = null, $min = null, $max = null, $value = null) { return $this->appendChild($this->createElementInputTime($name, $id, $min, $max, $value)); } + public function appendInputDateTime($name, $id = null, $min = null, $max = null, $value = null) { + return $this->appendChild($this->createElementInputDateTime($name, $id, $min, $max, $value)); + } public function appendInputColor($name, $id = null, $value = null) { return $this->appendChild($this->createElementInputColor($name, $id, $value)); } @@ -613,6 +624,17 @@ class ExtendedDocument extends DOMDocument { return $timefield; } + public function createElementInputDateTime($name, $id = null, $min = null, $max = null, $value = null) { + $dtfield = $this->createElement('input'); + $dtfield->setAttribute('type', 'datetime-local'); + if (!is_null($id)) { $dtfield->setAttribute('id', $id); } + $dtfield->setAttribute('name', $name); + if (!is_null($min)) { $dtfield->setAttribute('min', $min); } + if (!is_null($max)) { $dtfield->setAttribute('max', $max); } + if (!is_null($value)) { $dtfield->setAttribute('value', str_replace(' ', 'T', $value, 1)); } + return $dtfield; + } + public function createElementInputColor($name, $id = null, $value = null) { $colfield = $this->createElement('input'); $colfield->setAttribute('type', 'color'); @@ -815,6 +837,10 @@ class ExtendedElement extends DOMElement { // appends an ExtendedDocument::createElementInputTime() as a child of this element (see there for params) // returns the new child // + // public function appendInputDateTime($name, [$id], [$min], [$max], [$value]) + // appends an ExtendedDocument::createElementInputDateTime() as a child of this element (see there for params) + // returns the new child + // // public function appendInputColor($name, [$id], [$value]) // appends an ExtendedDocument::createElementInputColor() as a child of this element (see there for params) // @@ -963,6 +989,9 @@ class ExtendedElement extends DOMElement { public function appendInputTime($name, $id = null, $min = null, $max = null, $value = null) { return $this->appendChild($this->ownerDocument->createElementInputTime($name, $id, $min, $max, $value)); } + public function appendInputDateTime($name, $id = null, $min = null, $max = null, $value = null) { + return $this->appendChild($this->ownerDocument->createElementInputDateTime($name, $id, $min, $max, $value)); + } public function appendInputColor($name, $id = null, $value = null) { return $this->appendChild($this->ownerDocument->createElementInputColor($name, $id, $value)); } @@ -1114,6 +1143,10 @@ class ExtendedDocumentFragment extends DOMDocumentFragment { // appends an ExtendedDocument::createElementInputTime() as a child of this fragment (see there for params) // returns the new child // + // public function appendInputDateTime($name, [$id], [$min], [$max], [$value]) + // appends an ExtendedDocument::createElementInputDateTime() as a child of this fragment (see there for params) + // returns the new child + // // public function appendInputColor($name, [$id], [$value]) // appends an ExtendedDocument::createElementInputColor() as a child of this fragment (see there for params) // @@ -1252,6 +1285,9 @@ class ExtendedDocumentFragment extends DOMDocumentFragment { public function appendInputTime($name, $id = null, $min = null, $max = null, $value = null) { return $this->appendChild($this->ownerDocument->createElementInputTime($name, $id, $min, $max, $value)); } + public function appendInputDateTime($name, $id = null, $min = null, $max = null, $value = null) { + return $this->appendChild($this->ownerDocument->createElementInputDateTime($name, $id, $min, $max, $value)); + } public function appendInputColor($name, $id = null, $value = null) { return $this->appendChild($this->ownerDocument->createElementInputColor($name, $id, $value)); } -- 2.35.3