From 262e0bbb3441a51237f0330fa5ed7e53e70baf0e Mon Sep 17 00:00:00 2001 From: Robert Kaiser Date: Fri, 30 Sep 2016 00:46:24 +0200 Subject: [PATCH] add support for number inputs to ExtendedDocument --- include/cbsm/util/document.php-class | 36 ++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/include/cbsm/util/document.php-class b/include/cbsm/util/document.php-class index 1563e9f..c64d9a4 100755 --- a/include/cbsm/util/document.php-class +++ b/include/cbsm/util/document.php-class @@ -66,6 +66,10 @@ class ExtendedDocument extends DOMDocument { // appends an ExtendedDocument::createElementInputText() as a child of this document (see there for params) // returns the new child // + // function appendInputNumber($name, $maxlength, $size, [$id], [$value]) + // appends an ExtendedDocument::createElementInputNumber() as a child of this document (see there for params) + // returns the new child + // // function appendInputPassword($name, $maxlength, $size, [$id], [$value]) // appends an ExtendedDocument::createElementInputPassword() as a child of this document (see there for params) // returns the new child @@ -143,6 +147,10 @@ class ExtendedDocument extends DOMDocument { // returns an ExtendedElement that is an HTML of type 'text' with the given name, maxlength, size, // and optionally id and value // + // function createElementInputNumber($name, $maxlength, $size, [$id], [$value]) + // returns an ExtendedElement that is an HTML of type 'number' with the given name, maxlength, size, + // and optionally id and value + // // function createElementInputPassword($name, $maxlength, $size, [$id], [$value]) // returns an ExtendedElement that is an HTML of type 'password' with the given name, maxlength, size, // and optionally id and value @@ -221,6 +229,9 @@ class ExtendedDocument extends DOMDocument { function appendInputText($name, $maxlength, $size, $id = null, $value = null) { return $this->appendChild($this->createElementInputText($name, $maxlength, $size, $id, $value)); } + function appendInputNumber($name, $maxlength, $size, $id = null, $value = null) { + return $this->appendChild($this->createElementInputNumber($name, $maxlength, $size, $id, $value)); + } function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) { return $this->appendChild($this->createElementInputPassword($name, $maxlength, $size, $id, $value)); } @@ -321,6 +332,17 @@ class ExtendedDocument extends DOMDocument { return $txfield; } + function createElementInputNumber($name, $maxlength, $size, $id = null, $value = null) { + $txfield = $this->createElement('input'); + $txfield->setAttribute('type', 'number'); + if (!is_null($id)) { $txfield->setAttribute('id', $id); } + $txfield->setAttribute('name', $name); + $txfield->setAttribute('maxlength', $maxlength); + $txfield->setAttribute('size', $size); + if (!is_null($value)) { $txfield->setAttribute('value', $value); } + return $txfield; + } + function createElementInputPassword($name, $maxlength, $size, $id = null, $value = null) { $pwfield = $this->createElement('input'); $pwfield->setAttribute('type', 'password'); @@ -454,6 +476,10 @@ class ExtendedElement extends DOMElement { // appends an ExtendedDocument::createElementInputText() as a child of this element (see there for params) // returns the new child // + // function appendInputNumber($name, $maxlength, $size, [$id], [$value]) + // appends an ExtendedDocument::createElementInputNumber() as a child of this element (see there for params) + // returns the new child + // // function appendInputPassword($name, $maxlength, $size, [$id], [$value]) // appends an ExtendedDocument::createElementInputPassword() as a child of this element (see there for params) // returns the new child @@ -544,6 +570,9 @@ class ExtendedElement extends DOMElement { function appendInputText($name, $maxlength, $size, $id = null, $value = null) { return $this->appendChild($this->ownerDocument->createElementInputText($name, $maxlength, $size, $id, $value)); } + function appendInputNumber($name, $maxlength, $size, $id = null, $value = null) { + return $this->appendChild($this->ownerDocument->createElementInputNumber($name, $maxlength, $size, $id, $value)); + } function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) { return $this->appendChild($this->ownerDocument->createElementInputPassword($name, $maxlength, $size, $id, $value)); } @@ -628,6 +657,10 @@ class ExtendedDocumentFragment extends DOMDocumentFragment { // appends an ExtendedDocument::createElementInputText() as a child of this fragment (see there for params) // returns the new child // + // function appendInputNumber($name, $maxlength, $size, [$id], [$value]) + // appends an ExtendedDocument::createElementInputNumber() as a child of this fragment (see there for params) + // returns the new child + // // function appendInputPassword($name, $maxlength, $size, [$id], [$value]) // appends an ExtendedDocument::createElementInputPassword() as a child of this fragment (see there for params) // returns the new child @@ -718,6 +751,9 @@ class ExtendedDocumentFragment extends DOMDocumentFragment { function appendInputText($name, $maxlength, $size, $id = null, $value = null) { return $this->appendChild($this->ownerDocument->createElementInputText($name, $maxlength, $size, $id, $value)); } + function appendInputNumber($name, $maxlength, $size, $id = null, $value = null) { + return $this->appendChild($this->ownerDocument->createElementInputNumber($name, $maxlength, $size, $id, $value)); + } function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) { return $this->appendChild($this->ownerDocument->createElementInputPassword($name, $maxlength, $size, $id, $value)); } -- 2.43.0