Skip to content

Commit 5a268aa

Browse files
authored
Merge pull request #140 from devforth/fix-empty-number-input
fix: change empty number input to become null
2 parents be7badd + 93329c4 commit 5a268aa

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

adminforth/spa/src/components/ResourceForm.vue

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,12 @@ const setCurrentValue = (key, value, index=null) => {
190190
} else if (index === currentValues.value[key].length) {
191191
currentValues.value[key].push(null);
192192
} else {
193-
if (['integer', 'float'].includes(col.isArray.itemType) && (value || value === 0)) {
194-
currentValues.value[key][index] = +value;
193+
if (['integer', 'float', 'decimal'].includes(col.isArray.itemType)) {
194+
if (value || value === 0) {
195+
currentValues.value[key][index] = +value;
196+
} else {
197+
currentValues.value[key][index] = null;
198+
}
195199
} else {
196200
currentValues.value[key][index] = value;
197201
}
@@ -200,8 +204,12 @@ const setCurrentValue = (key, value, index=null) => {
200204
}
201205
}
202206
} else {
203-
if (['integer', 'float'].includes(col.type) && (value || value === 0)) {
204-
currentValues.value[key] = +value;
207+
if (['integer', 'float', 'decimal'].includes(col.type)) {
208+
if (value || value === 0) {
209+
currentValues.value[key] = +value;
210+
} else {
211+
currentValues.value[key] = null;
212+
}
205213
} else {
206214
currentValues.value[key] = value;
207215
}

0 commit comments

Comments
 (0)