Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Andrew Camilleri 7 posts 78 karma points
    Nov 29, 2020 @ 15:37
    Andrew Camilleri
    0

    Umbraco REgistration control 'UmbRegisterController' issue with registering custom data

    Hi I found a snippet within Umbraco that helps with registering members, While the out of the box properties are saved upon creation the custom properties are visible on the frontend but are not saved upon submit.

    I'm pretty sure some people are familiar as i found multiple posts on this however no solutions so far.

      using (Html.BeginUmbracoForm<UmbRegisterController>("HandleRegisterMember"))
    {
        <fieldset>
            <legend>Register Member</legend>
    
            @Html.ValidationSummary("registerModel", true)
    
            @Html.LabelFor(m => registerModel.Name)
            @Html.TextBoxFor(m => registerModel.Name)
            @Html.ValidationMessageFor(m => registerModel.Name)
            <br />
    
            @Html.LabelFor(m => registerModel.Email)
            @Html.TextBoxFor(m => registerModel.Email)
            @Html.ValidationMessageFor(m => registerModel.Email)
            <br />
    
            @Html.LabelFor(m => registerModel.Password)
            @Html.PasswordFor(m => registerModel.Password)
            @Html.ValidationMessageFor(m => registerModel.Password)
            <br />
    
            @if (registerModel.MemberProperties != null)
            {
                @*
                    It will only displays properties marked as "Member can edit" on the "Info" tab of the Member Type.
                *@
                for (var i = 0; i < registerModel.MemberProperties.Count; i++)
                {
    
                    @Html.LabelFor(m => registerModel.MemberProperties[i].Value, registerModel.MemberProperties[i].Name)
                    @*
                        By default this will render a textbox but if you want to change the editor template for this property you can
                        easily change it. For example, if you wanted to render a custom editor for this field called "MyEditor" you would
                        create a file at ~/Views/Shared/EditorTemplates/MyEditor.cshtml", then you will change the next line of code to
                        render your specific editor template like:
                        @Html.EditorFor(m => registerModel.MemberProperties[i].Value, "MyEditor")
                    *@
    
    
                    if (registerModel.MemberProperties[i].Alias.ToLower().Contains("jobposter") || registerModel.MemberProperties[i].Alias.ToLower().Contains("jobseaker"))
                    {
                        @Html.EditorFor(m => registerModel.MemberProperties[i], "CheckboxEditor")
                    }
                    else
                    {
                        @Html.EditorFor(m => registerModel.MemberProperties[i].Value, registerModel.MemberProperties[i].Alias)
                    }
                    @Html.HiddenFor(m => registerModel.MemberProperties[i].Alias)
                    <br />
                }
            }
    
            @Html.HiddenFor(m => registerModel.MemberTypeAlias)
            @Html.HiddenFor(m => registerModel.RedirectUrl)
            @Html.HiddenFor(m => registerModel.UsernameIsEmail)
    
            <button>Register</button>
        </fieldset>
    }
    

    }

    [Update] Kindly visit the following link for an answer: https://our.umbraco.com/forum/umbraco-7/using-umbraco-7/56980-RegisterModelMemberProperties-empty

Please Sign in or register to post replies

Write your reply to:

Draft