Skip to content

Commit

Permalink
fix(entities-plugins): edit number array fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Leopoldthecoder committed Aug 8, 2024
1 parent 826a1f6 commit 74470ea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/core/forms/src/components/fields/FieldArray.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@

<KInput
v-else-if="!schema.inputAttributes || !schema.inputAttributes.type || schema.inputAttributes.type === 'text' || schema.inputAttributes.type === 'number'"
v-model="value[index]"
:aria-labelledby="getLabelId(schema)"
v-bind="schema.inputAttributes"
:model-value="value[index]"
:type="schema.inputAttributes && schema.inputAttributes.type || 'text'"
@input="(val) => { handleInput(val, index) }"
/>

<input
Expand Down Expand Up @@ -211,6 +212,9 @@ export default {
return 'field-' + fieldSchema.type
},
modelUpdated() {},
handleInput(val, index) {
this.value = this.value.map((item, i) => i === index ? val : item)
},
},
}
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,8 @@ const getModel = (): Record<string, any> => {
} else if (fieldSchemaValueType === 'array') {
if ((!fieldValue || !fieldValue.length)) {
fieldValue = fieldSchema.submitWhenNull ? null : []
} else if (fieldSchema.inputAttributes?.type === 'number') {
fieldValue = fieldValue.map((value: string) => Number(value))
}
}
Expand Down

0 comments on commit 74470ea

Please sign in to comment.