diff --git a/resources/ts/components/BelongsToDropdown.vue b/resources/ts/components/BelongsToDropdown.vue index 8accf2a..4d2c912 100644 --- a/resources/ts/components/BelongsToDropdown.vue +++ b/resources/ts/components/BelongsToDropdown.vue @@ -109,18 +109,20 @@ export default defineComponent({ methods: { parseTags(intSelectedItem: number[]): CustomTag[] { const out: CustomTag[] = []; - intSelectedItem.forEach((intItem: number) => { - const selectedItem = this.allItems.find(item => String(item.id) === String(intItem)); - if (!selectedItem) { - console.debug(intItem); - throw new Error(`Could not find enum ${intItem}`); - } - out.push({ - id: String(selectedItem.id), - value: String(selectedItem.id), - text: String(selectedItem[`${this.labelField}`]) - } as LaravelModel as CustomTag); - }); + if (intSelectedItem[0] !== null) { + intSelectedItem.forEach((intItem: number) => { + const selectedItem = this.allItems.find(item => String(item.id) === String(intItem)); + if (!selectedItem) { + console.debug(intItem); + throw new Error(`Could not find enum ${intItem}`); + } + out.push({ + id: String(selectedItem.id), + value: String(selectedItem.id), + text: String(selectedItem[`${this.labelField}`]) + } as LaravelModel as CustomTag); + }); + } return out; }, parseNewlyCreated(newModel: LaravelModel): CustomTag {