I have a working people picker on a .Net Create, I followed the following stack overflow to get that working: How to get input values from mgt-people-picker when a FORM is submitted
...the mgt component documentation leaves a lot to be desired.
In my form I have the following:
<mgt-people-picker selection-mode="single">
<template data-type="selected-person">
<input type="hidden" value="{{person.userPrincipalName}}" name="selectedPerson" id="transmissionEstimator" />
@if (CREATE CONDITION)
{
<mgt-person view="oneLine" person-details="{{person}}" fetchImage=true></mgt-person>
}
else
{
var selectedPerson = @Html.Raw(Json.Encode("emailstringfrom@backend.com"));
<mgt-person view="oneLine" person-details="{{person}}" defaultSelectedUserIds=@selectedPerson fetchImage=true></mgt-person>
}
</template>
</mgt-people-picker>
In my backend Save function I have the following:
Request.Form["selectedPerson"];
So I'm able to add users in the CREATE condition, but when I trigger the edit version of the form (confirmed via breakpoint), I expect to see the user that was selected as the default selected user on the component.(Their email was stored and is now coming from the database)
Looking at the element (Dev Tools - F12) I see that the property has been populated! (I removed the email for privacy reasons. But it is in in the format {["user@domain.com"]} and is being passed in via ViewModel to defaultSelectedUserIds
And still no dice...
Some more things I've tried also tried these formats using the attribute version of default-selected-user-ids
- [{"user@domain.com"}]
- {"user@domain.com"}
- "user@domain.com"
Is my formatting incorrect? Am I not passing the value in correctly?
Any help would be greatly appreciated!