mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-16 19:50:44 +01:00
Etemplate - fix bug where min / max could not be 0
This commit is contained in:
parent
4d68048929
commit
12ae214b76
@ -177,12 +177,12 @@ class Textbox extends Etemplate\Widget
|
||||
{
|
||||
$value = $this->attrs['type'] == 'integer' ? (int) $value : (float) str_replace(',','.',$value); // allow for german (and maybe other) format
|
||||
|
||||
if (!empty($this->attrs['min']) && $value < $this->attrs['min'])
|
||||
if (!(empty($this->attrs['min']) && $this->attrs['min'] !== 0) && $value < $this->attrs['min'])
|
||||
{
|
||||
self::set_validation_error($form_name,lang("Value has to be at least '%1' !!!",$this->attrs['min']),'');
|
||||
$value = $this->attrs['type'] == 'integer' ? (int) $this->attrs['min'] : (float) $this->attrs['min'];
|
||||
}
|
||||
if (!empty($this->attrs['max']) && $value > $this->attrs['max'])
|
||||
if (!(empty($this->attrs['max'])&& $this->attrs['max'] !== 0) && $value > $this->attrs['max'])
|
||||
{
|
||||
self::set_validation_error($form_name,lang("Value has to be at maximum '%1' !!!",$this->attrs['max']),'');
|
||||
$value = $this->attrs['type'] == 'integer' ? (int) $this->attrs['max'] : (float) $this->attrs['max'];
|
||||
|
@ -82,8 +82,8 @@ class FloatTest extends \EGroupware\Api\Etemplate\WidgetBaseTest {
|
||||
);
|
||||
$result = $this->mockedExec($etemplate, $content, array(), array(), array());
|
||||
|
||||
// Only lowercase
|
||||
$etemplate->getElementById('widget')->attrs['min'] = $min;
|
||||
$etemplate->getElementById('widget')->attrs['max'] = null;
|
||||
|
||||
// Check for the load
|
||||
$data = array();
|
||||
@ -114,16 +114,16 @@ class FloatTest extends \EGroupware\Api\Etemplate\WidgetBaseTest {
|
||||
public function minProvider()
|
||||
{
|
||||
return Array(
|
||||
// User value, Min, Error
|
||||
// User value, Min, Error
|
||||
array('', 0, FALSE),
|
||||
array(1.0, 0, FALSE),
|
||||
array(0.0, 0, FALSE),
|
||||
array(-1.0, 0, TRUE),
|
||||
array(1.5, 0, FALSE),
|
||||
array(1, 10, FALSE),
|
||||
array(1, 10, TRUE),
|
||||
array(10, 10, FALSE),
|
||||
array(1.5, 1.5, FALSE),
|
||||
array(2, 1.5, TRUE),
|
||||
array(0.5, 1.5, TRUE),
|
||||
);
|
||||
}
|
||||
|
||||
@ -149,7 +149,7 @@ class FloatTest extends \EGroupware\Api\Etemplate\WidgetBaseTest {
|
||||
);
|
||||
$result = $this->mockedExec($etemplate, $content, array(), array(), array());
|
||||
|
||||
// Only lowercase
|
||||
$etemplate->getElementById('widget')->attrs['min'] = null;
|
||||
$etemplate->getElementById('widget')->attrs['max'] = $max;
|
||||
|
||||
// Check for the load
|
||||
@ -191,7 +191,7 @@ class FloatTest extends \EGroupware\Api\Etemplate\WidgetBaseTest {
|
||||
array(10, 10, FALSE),
|
||||
array(2.5, 2, TRUE),
|
||||
array(1.5, 2.5, FALSE),
|
||||
array(3, 2.5, FALSE),
|
||||
array(3, 2.5, TRUE),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user