forked from extern/egroupware
make eTemplate widget-type integer an alias for int, to ease backporting templates from trunk
This commit is contained in:
parent
b46eb9a72c
commit
70dbb95d6e
@ -1249,6 +1249,7 @@ class etemplate_old extends boetemplate
|
|||||||
$html .= $value;
|
$html .= $value;
|
||||||
break;
|
break;
|
||||||
case 'int': // size: [min],[max],[len],[precision/sprint format],[step]
|
case 'int': // size: [min],[max],[len],[precision/sprint format],[step]
|
||||||
|
case 'integer':
|
||||||
case 'float':
|
case 'float':
|
||||||
list($min,$max,$cell_options,$pre,$step) = explode(',',$cell_options);
|
list($min,$max,$cell_options,$pre,$step) = explode(',',$cell_options);
|
||||||
// a few html5 options
|
// a few html5 options
|
||||||
@ -1261,7 +1262,7 @@ class etemplate_old extends boetemplate
|
|||||||
}
|
}
|
||||||
if ($cell_options == '' && !$readonly)
|
if ($cell_options == '' && !$readonly)
|
||||||
{
|
{
|
||||||
$cell_options = $cell['type'] == 'int' ? 5 : 8;
|
$cell_options = $cell['type'] != 'float' ? 5 : 8;
|
||||||
}
|
}
|
||||||
// html5 input type=nummeric seems to ignore size, setting a width instead
|
// html5 input type=nummeric seems to ignore size, setting a width instead
|
||||||
$options .= ' style="width: '.(3+abs($cell_options)).'ex"';
|
$options .= ' style="width: '.(3+abs($cell_options)).'ex"';
|
||||||
@ -1269,7 +1270,7 @@ class etemplate_old extends boetemplate
|
|||||||
{
|
{
|
||||||
$value = is_numeric($pre) ? self::number_format($value,$pre,$readonly) : sprintf($pre,$value);
|
$value = is_numeric($pre) ? self::number_format($value,$pre,$readonly) : sprintf($pre,$value);
|
||||||
}
|
}
|
||||||
$cell_options .= ',,'.($cell['type'] == 'int' ? '/^-?[0-9]*$/' : '"/^-?[0-9]*[,.]?[0-9]*$/"').',number';
|
$cell_options .= ',,'.($cell['type'] != 'float' ? '/^-?[0-9]*$/' : '"/^-?[0-9]*[,.]?[0-9]*$/"').',number';
|
||||||
// fall-through
|
// fall-through
|
||||||
case 'hidden':
|
case 'hidden':
|
||||||
case 'passwd':
|
case 'passwd':
|
||||||
@ -2281,6 +2282,7 @@ class etemplate_old extends boetemplate
|
|||||||
}
|
}
|
||||||
// fall-throught for mode 'ascii', which is identical to textarea
|
// fall-throught for mode 'ascii', which is identical to textarea
|
||||||
case 'int':
|
case 'int':
|
||||||
|
case 'integer':
|
||||||
case 'float':
|
case 'float':
|
||||||
case 'passwd':
|
case 'passwd':
|
||||||
case 'text':
|
case 'text':
|
||||||
@ -2301,6 +2303,7 @@ class etemplate_old extends boetemplate
|
|||||||
switch($type)
|
switch($type)
|
||||||
{
|
{
|
||||||
case 'int':
|
case 'int':
|
||||||
|
case 'integer':
|
||||||
self::set_validation_error($form_name,lang("'%1' is not a valid integer !!!",$value),'');
|
self::set_validation_error($form_name,lang("'%1' is not a valid integer !!!",$value),'');
|
||||||
break;
|
break;
|
||||||
case 'float':
|
case 'float':
|
||||||
@ -2311,21 +2314,21 @@ class etemplate_old extends boetemplate
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($type == 'int' || $type == 'float') // cast int and float and check range
|
elseif (in_array($type, array('int', 'integer', 'float'))) // cast int and float and check range
|
||||||
{
|
{
|
||||||
if ((string)$value !== '' || $attr['needed']) // empty values are Ok if needed is not set
|
if ((string)$value !== '' || $attr['needed']) // empty values are Ok if needed is not set
|
||||||
{
|
{
|
||||||
$value = $type == 'int' ? (int) $value : (float) str_replace(',','.',$value); // allow for german (and maybe other) format
|
$value = $type != 'float' ? (int) $value : (float) str_replace(',','.',$value); // allow for german (and maybe other) format
|
||||||
|
|
||||||
if (!empty($attr['min']) && $value < $attr['min'])
|
if (!empty($attr['min']) && $value < $attr['min'])
|
||||||
{
|
{
|
||||||
self::set_validation_error($form_name,lang("Value has to be at least '%1' !!!",$attr['min']),'');
|
self::set_validation_error($form_name,lang("Value has to be at least '%1' !!!",$attr['min']),'');
|
||||||
$value = $type == 'int' ? (int) $attr['min'] : (float) $attr['min'];
|
$value = $type != 'float' ? (int) $attr['min'] : (float) $attr['min'];
|
||||||
}
|
}
|
||||||
if (!empty($attr['max']) && $value > $attr['max'])
|
if (!empty($attr['max']) && $value > $attr['max'])
|
||||||
{
|
{
|
||||||
self::set_validation_error($form_name,lang("Value has to be at maximum '%1' !!!",$attr['max']),'');
|
self::set_validation_error($form_name,lang("Value has to be at maximum '%1' !!!",$attr['max']),'');
|
||||||
$value = $type == 'int' ? (int) $attr['max'] : (float) $attr['max'];
|
$value = $type != 'float' ? (int) $attr['max'] : (float) $attr['max'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user