added precision to the float widget

This commit is contained in:
Ralf Becker 2006-03-27 12:21:29 +00:00
parent 5d29337843
commit ddde44ea3c
3 changed files with 9 additions and 4 deletions

View File

@ -430,10 +430,11 @@ implement only a subset of XUL. Here are the main differences:</p>
<b>a input-field to enter a float</b><br />
In the html-UI this is rendered as &lt;input ...>. <i>The input-validation is done at the moment only on server-side,
clientside validation and input-restriction to only numbers is planed.</i><p>
<b>Options</b> has 3 comma-separated fields:<br />
<b>Options</b> has 4 comma-separated fields:<br />
xml: <b>min</b>: minimum value, default none, empty values are Ok, as long as <b>needed</b> is not set<br />
xml: <b>max</b>: maximum value, default none, empty values are Ok, as long as <b>needed</b> is not set<br />
xml: <b>size</b>: the length in chars of the input-field, default 5
xml: <b>precision</b>: precision of the float number, default maximum
</td>
</tr>
<tr>

View File

@ -893,13 +893,17 @@
list($extra_link,$extra_link_target,$extra_link_popup) = explode(',',$cell_options);
$html .= $value;
break;
case 'int': // size: [min][,[max][,len]]
case 'int': // size: [min],[max],[len],[precission (only float)]
case 'float':
list($min,$max,$cell_options) = explode(',',$cell_options);
list($min,$max,$cell_options,$pre) = explode(',',$cell_options);
if ($cell_options == '')
{
$cell_options = $cell['type'] == 'int' ? 5 : 8;
}
if ($type == 'float' && $value && $pre)
{
$value = round($value,$pre);
}
$cell_options .= ',,'.($cell['type'] == 'int' ? '/^-?[0-9]*$/' : '/^-?[0-9]*[,.]?[0-9]*$/');
// fall-through
case 'text': // size: [length][,maxLength[,preg]]

View File

@ -79,7 +79,7 @@
'float' => array(
'.name' => 'textbox',
'.set' => 'type=float',
'size' => 'min,max,size'
'size' => 'min,max,size,precision'
),
'select' => array(
'.name' => 'menulist,menupopup',