Skip to content

Commit

Permalink
DataList default value for multiple
Browse files Browse the repository at this point in the history
  • Loading branch information
amandine-sahl committed Jul 26, 2024
1 parent 2337d76 commit b58f670
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,16 @@ export class DatalistComponent extends GenericFormComponent implements OnInit {
const val = this.values[0][this.keyValue];
this.parentFormControl.patchValue(this.multiple ? [val] : val);
}

// valeur par défaut (depuis input value)
if (!this.parentFormControl.value && this.default) {
if (
(!this.parentFormControl.value ||
(Array.isArray(this.parentFormControl.value) &&
this.parentFormControl.value.length == 0)) &&
this.default
) {
const value = this.multiple ? this.default : [this.default];

const res = value.map((val) =>
typeof val === 'object'
? (this.filteredValues.find((v) =>
Expand Down

0 comments on commit b58f670

Please sign in to comment.