[Solved] Getting Umbraco Member Email into an Umbr...
# help-with-umbraco
c
V13.5.2 Can anyone suggest a way of getting a Member's email address into a UF form field and return address? The form is added to a View as follows:-
Copy code
@Html.RenderUmbracoFormDependencies(Url)

    @if (Model.FormPicker.HasValue) {
        @await Component.InvokeAsync("RenderForm", new { formId = @Model.FormPicker.Value, theme = "MyTheme", includeScripts = true })
    }
I've tried and failed with various options with "prepopulatedData" as suggested by ChatGPT but they were a waste of time, including using a ViewComponent and partial. I don't particularly want to create a special workflow for every form, I was hoping someone could suggest how to do it with magic strings in the form set up. Tried getting the Member email into a hidden field but one issue is getting it to appear before the form is sent for rendering. Any suggestions would be greatly appreciated. Thanks.
r
Hmm I just saw this … https://discord.com/channels/869656431308189746/1329730293380284416 and wondered if there might be bits and bobs that you could use to fix your issue.. Though I don’t known if this is sledgehammer to crack a peanut
m
You've probably seen this but.. https://docs.umbraco.com/umbraco-forms/developer/magic-strings#member-properties-from-a-form-submission
Copy code
Member properties from a form submission
{member.FOO} with the prefix of member, the same syntax will allow you to retrieve information about the submission if it was submitted by a logged-in member.
FYI I think I've also had problems with UForms in ViewComponents so had to stick with Partials...
Actually was vanilla MVC and model hydration in a form.. had to manually fetch the data from the ModelState and hydrate the model manually...
Copy code
csharp
 @*Not sure why we have to do this, but the page Model isn't correcty rehydrated*@
 ViewData.ModelState.TryGetValue("CallToDiscuss", out var callToDiscuss);
 ViewData.ModelState.TryGetValue("CallBackConsent", out var callBackConsent);
 ViewData.ModelState.TryGetValue("LocationPreferences", out var locationPreference);


 string showCallOptions = bool.Parse(callToDiscuss?.AttemptedValue ?? "False") ? "" : " visually-hidden";
 string showAllForm = ( callBackConsent?.AttemptedValue?.Split(",")?.Contains("true") ?? false ) ? "" : " visually-hidden";
 var locationPreferences = locationPreference?.AttemptedValue?.Split(",");
c
I can't believe that I spent an embarrassing number of hours chasing this yesterday and all it was was [member.email] in the form workflow!!!! "If at first you don't succeed....... read the instructions!" Tbf, I did read the instructions but didn't cotton on to what they were trying to tell me. But thanks so much 🙂
5 Views