diff --git a/modules/backend/assets/css/october.css b/modules/backend/assets/css/october.css index 070d504e0..1d5734cc0 100644 --- a/modules/backend/assets/css/october.css +++ b/modules/backend/assets/css/october.css @@ -7392,6 +7392,9 @@ label { .form-group.checkbox-field { padding-bottom: 5px; } +.form-group.number-field > .form-control { + text-align: right; +} .form-group.checkbox-align { padding-left: 23px; margin-top: -5px; diff --git a/modules/backend/assets/less/controls/forms.less b/modules/backend/assets/less/controls/forms.less index 22eafffe4..b903efa8f 100644 --- a/modules/backend/assets/less/controls/forms.less +++ b/modules/backend/assets/less/controls/forms.less @@ -129,6 +129,10 @@ label { padding-bottom: 5px; } + &.number-field { + > .form-control { text-align: right; } + } + &.checkbox-align { padding-left: 23px; margin-top: -5px; diff --git a/modules/backend/widgets/Form.php b/modules/backend/widgets/Form.php index 84d40ce17..7d8772b51 100644 --- a/modules/backend/widgets/Form.php +++ b/modules/backend/widgets/Form.php @@ -533,9 +533,11 @@ class Form extends WidgetBase /* * Boolean fields (checkbox, switch) won't be present value FALSE + * Number fields should be converted to integers */ foreach ($this->allFields as $field) { - if ($field->type != 'switch' && $field->type != 'checkbox') + + if (!in_array($field->type, ['switch', 'checkbox', 'number'])) continue; /* @@ -544,6 +546,7 @@ class Form extends WidgetBase $columnParts = Str::evalHtmlArray($field->columnName); $columnDotted = implode('.', $columnParts); $columnValue = array_get($data, $columnDotted, 0); + if ($field->type == 'number') $columnValue = (int) $columnValue; array_set($data, $columnDotted, $columnValue); } diff --git a/modules/backend/widgets/form/partials/_field_number.htm b/modules/backend/widgets/form/partials/_field_number.htm new file mode 100644 index 000000000..58e6d7a86 --- /dev/null +++ b/modules/backend/widgets/form/partials/_field_number.htm @@ -0,0 +1,16 @@ + +previewMode): ?> + value ? e($field->value) : ' ' ?> + + attributes) ?> + /> + \ No newline at end of file