Skip to content

Commit

Permalink
tighten up multivalue normalization by covering 'any' type models and…
Browse files Browse the repository at this point in the history
… removing duplicate from base Component class
  • Loading branch information
brendanbond authored and lane-formio committed Sep 19, 2024
1 parent 820b011 commit 77a76dd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
3 changes: 0 additions & 3 deletions src/components/_classes/component/Component.js
Original file line number Diff line number Diff line change
Expand Up @@ -3001,9 +3001,6 @@ export default class Component extends Element {
* @returns {*} - The normalized value.
*/
normalizeValue(value) {
if (this.component.multiple && !Array.isArray(value)) {
value = value ? [value] : [];
}
return value;
}

Expand Down
6 changes: 3 additions & 3 deletions src/components/_classes/multivalue/Multivalue.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ export default class Multivalue extends Field {
}
} else {
if (Array.isArray(value) && !underlyingValueShouldBeArray) {
if (Utils.getModelType(this.component) === 'any') {
return super.normalizeValue(value, flags);
}
if (this.component.storeas === 'string') {
return super.normalizeValue(value.join(this.delimiter || ''), flags);
}
if (this.component.type === 'hidden' && value.length > 1) {
return super.normalizeValue(value, flags);
}
return super.normalizeValue(value[0] || emptyValue, flags);
} else {
return super.normalizeValue(value, flags);
Expand Down

0 comments on commit 77a76dd

Please sign in to comment.