contao/import — Issue #3002: Numerical Range (low and high) for DCA
Author: importer
Created: 2011-11-29 20:40:43+00:00
State: open
Labels: Accepted, Feature, framework

Often a digit field will require a numerical range.
For instance Google Earths "setTerrainExaggeration" requires a number from 1.0 to 3.0 etc.
I think the ability to set a numerical range in the DCA would be great in Contao.

This below may not be exactly right but it seems to work well as far as I can see.
Added to Widget.php line 524 (after minlength/maxlength checks)

```
if ($this->low && strlen($varInput) && trim($varInput) < $this->low)
{
$this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['low'], $this->strLabel, $this->low));
}

if ($this->high && strlen($varInput) && trim($varInput) > $this->high)
{
$this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['high'], $this->strLabel, $this->high));
}
```

and error

```
$GLOBALS['TL_LANG']['ERR']['low'] = 'Field "%s" must not be a lower value than %d

![](';
$GLOBALS['TL_LANG']['ERR']['high'] = 'Field "%s" must not be a higher value than %d )';
```

and used in the DCA like this:

```
'balloonMaxWidth' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_earthblog']['balloonMaxWidth'],
'inputType' => 'text',
'eval' => array('maxlength'=>4, 'rgxp'=>'digit', 'low'=>50, 'high'=>500),
'default' => 300
)
```

--- _Originally created by ramjet on April 11th, 2011, at 02:15pm (ID 3002)_