Skip to content

Commit 576275e

Browse files
authored
Merge pull request davidkpiano#1008 from galkinrost/master
Prevent changing values from array type to object
2 parents 3de4239 + aaa4fa8 commit 576275e

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/utils/get-form-value.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import mapValues from './map-values';
2+
import toArray from './to-array';
23

34
export default function getFormValue(form) {
45
if (form && !form.$form) {
@@ -15,5 +16,7 @@ export default function getFormValue(form) {
1516

1617
delete result.$form;
1718

18-
return result;
19+
const isArray = form && form.$form && Array.isArray(form.$form.value);
20+
21+
return isArray ? toArray(result) : result;
1922
}

src/utils/to-array.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export default function toArray(object) {
2+
const result = [];
3+
Object.keys(object).forEach(key => {
4+
if (object.hasOwnProperty(key)) {
5+
result.push(object[key]);
6+
}
7+
});
8+
return result;
9+
}

0 commit comments

Comments
 (0)