1
0
mirror of https://github.com/EGroupware/egroupware.git synced 2025-03-10 21:18:37 +01:00

some fixes for int/float widget: server-side was not expanding min/max attribute and client-side considers empty min/max attr as 0

This commit is contained in:
Ralf Becker 2021-01-22 17:24:55 +02:00
parent fe320938e5
commit 8425f380fe
3 changed files with 12 additions and 10 deletions
api

View File

@ -135,13 +135,13 @@ var et2_number = /** @class */ (function (_super) {
}, },
"min": { "min": {
"name": "Minimum", "name": "Minimum",
"type": "integer", "type": "any",
"default": et2_no_init, "default": et2_no_init,
"description": "Minimum allowed value" "description": "Minimum allowed value"
}, },
"max": { "max": {
"name": "Maximum", "name": "Maximum",
"type": "integer", "type": "any",
"default": et2_no_init, "default": et2_no_init,
"description": "Maximum allowed value" "description": "Maximum allowed value"
}, },

View File

@ -33,13 +33,13 @@ export class et2_number extends et2_textbox
}, },
"min": { "min": {
"name": "Minimum", "name": "Minimum",
"type": "integer", "type": "any",
"default": et2_no_init, "default": et2_no_init,
"description": "Minimum allowed value" "description": "Minimum allowed value"
}, },
"max": { "max": {
"name": "Maximum", "name": "Maximum",
"type": "integer", "type": "any",
"default": et2_no_init, "default": et2_no_init,
"description": "Maximum allowed value" "description": "Maximum allowed value"
}, },

View File

@ -156,15 +156,17 @@ class Textbox extends Etemplate\Widget
{ {
$value = $this->attrs['type'] == 'integer' ? (int) $value : (float) str_replace(',','.',$value); // allow for german (and maybe other) format $value = $this->attrs['type'] == 'integer' ? (int) $value : (float) str_replace(',','.',$value); // allow for german (and maybe other) format
if (!(empty($this->attrs['min']) && $this->attrs['min'] !== 0) && $value < $this->attrs['min']) $min = self::expand_name($this->attrs['min'], $expand['c'], $expand['row'], $expand['c_'], $expand['row_'], $expand['cont']);
if (!(empty($min) && $min !== 0) && $value < $min)
{ {
self::set_validation_error($form_name,lang("Value has to be at least '%1' !!!",$this->attrs['min']),''); self::set_validation_error($form_name, lang("Value has to be at least '%1' !!!", $min),'');
$value = $this->attrs['type'] == 'integer' ? (int) $this->attrs['min'] : (float) $this->attrs['min']; $value = $this->attrs['type'] == 'integer' ? (int) $min : (float) $min;
} }
if (!(empty($this->attrs['max'])&& $this->attrs['max'] !== 0) && $value > $this->attrs['max']) $max = self::expand_name($this->attrs['max'], $expand['c'], $expand['row'], $expand['c_'], $expand['row_'], $expand['cont']);
if (!(empty($max) && $max !== 0) && $value > $max)
{ {
self::set_validation_error($form_name,lang("Value has to be at maximum '%1' !!!",$this->attrs['max']),''); self::set_validation_error($form_name, lang("Value has to be at maximum '%1' !!!", $max),'');
$value = $this->attrs['type'] == 'integer' ? (int) $this->attrs['max'] : (float) $this->attrs['max']; $value = $this->attrs['type'] == 'integer' ? (int) $max : (float) $max;
} }
} }
} }