Topic: A saved owner is not selected when the editor opens

briskbyte priority asked 1 week ago


The owner selector lists every available person, but opening an existing appointment leaves its selection blank. Choosing the same owner manually and saving works correctly.

The appointment API returns ownerId as a number. The option mapping converts IDs to strings, and the form is patched with the numeric value after both requests finish. Could that difference explain the missing initial selection?



Normalize the ID type on both sides of the binding. A numeric value and its string representation are different values for a strict comparison, so the form value may not match any option even though the visible IDs look identical.

Since your option adapter already produces strings, patch the form with String(appointment.ownerId) and handle an absent ID separately. Convert back at the API boundary only if your endpoint requires a numeric ID. Please share the selector template if consistent primitive types do not resolve the selection.

this.form.patchValue({
  ownerId: appointment.ownerId == null
    ? null
    : String(appointment.ownerId)
});

https://mdbootstrap.com/docs/angular/components/dropdowns/


briskbyte priority commented 1 week ago

Normalizing ownerId to a string fixed the initial selection. I tested creating an appointment and editing one with a different owner, and both now use the expected option. We also keep null for an appointment that has no assigned owner.



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Priority
  • Premium support: Yes
  • Technology: MDB Angular
  • MDB Version: MDB5 9.1.0
  • Device: Desktop
  • Browser: Firefox
  • OS: macOS
  • Provided sample code: No
  • Provided link: No