Skip to content

Commit 6a47435

Browse files
committed
Fix handling of unsigned int and float/decimal fields
1 parent bedc192 commit 6a47435

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

inc/object.class.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,11 @@ function displayField($canedit, $name, $value, $template, $description = []) {
614614
}
615615
$this->endColumn();
616616
$this->startColumn();
617-
switch (preg_replace('/\(\d+\)$/', '', $description['Type'])) {
617+
618+
// Keep only main column type by removing anything that is preceded by a space (e.g. " unsigned")
619+
// or a parenthesis (e.g. "(255)").
620+
$column_type = preg_replace('/[ (].+$/', '', $description['Type']);
621+
switch ($column_type) {
618622
case "int":
619623
$fk_table = getTableNameForForeignKeyField($name);
620624
if ($fk_table != '') {
@@ -710,14 +714,15 @@ function displayField($canedit, $name, $value, $template, $description = []) {
710714
);
711715
break;
712716

713-
default:
714717
case "float":
718+
case 'decimal':
719+
echo "<input type='number' name='$name' value='$value' step='any' />";
720+
break;
721+
722+
default:
715723
echo "<input type='text' name='$name' value='$value'>";
716724
break;
717725

718-
case 'decimal':
719-
echo "<input type='text' name='$name' value='".Html::formatNumber($value)."'>";
720-
break;
721726
}
722727
$this->endColumn();
723728
}

0 commit comments

Comments
 (0)