From d0f6befa7e12b23912901eeca3d450d2db9ae8ca Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sun, 19 Nov 2017 10:13:41 +0100 Subject: [PATCH] support number fields with min/max --- lam/lib/html.inc | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/lam/lib/html.inc b/lam/lib/html.inc index 99daf20e..7ccbe71f 100644 --- a/lam/lib/html.inc +++ b/lam/lib/html.inc @@ -455,6 +455,10 @@ class htmlInputField extends htmlElement { protected $sameValueFieldID = null; /** marks the input field as auto trimmed (remove spaces at start/end) */ protected $autoTrim = true; + /** minimum value */ + protected $minValue = null; + /** maximum value */ + protected $maxValue = null; /** * Constructor @@ -505,6 +509,14 @@ class htmlInputField extends htmlElement { if ($this->validationRule != null) { $validators[] = 'custom[' . $this->validationRule . ']'; } + $min = ''; + if ($this->minValue !== null) { + $min = ' min="' . $this->minValue . '"'; + } + $max = ''; + if ($this->maxValue !== null) { + $max = ' max="' . $this->maxValue . '"'; + } // print input field $class = ''; if (sizeof($validators) > 0) { @@ -533,6 +545,9 @@ class htmlInputField extends htmlElement { if ($this->isPassword) { $inputType = 'password'; } + elseif (($this->minValue !== null) || ($this->maxValue !== null)) { + $inputType = 'number'; + } $disabled = ''; if (!$this->isEnabled) { $disabled = ' disabled'; @@ -549,7 +564,8 @@ class htmlInputField extends htmlElement { if (!empty($this->title)) { $title = ' title="' . $this->title . '"'; } - echo ''; + echo ''; // autocompletion if ($this->autocomplete) { echo "