Copied to clipboard

Flag this post as spam?

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


  • Wayne Kruger 7 posts 28 karma points
    Sep 29, 2014 @ 14:22
    Wayne Kruger
    1

    RegisterModel.MemberProperties empty

    I created a custom member type and added a while bunch of properties to it.

    Using the Register Macro, I am unable to render the form woith all the properties. 

    Stepping through the code shows that the Register model gets created fine (using the Alias) but the RegisterModel.MemberProperties collection has a count of 0.

    Any suggestions?

     

    My code:

    @{    
        var registerModel = Members.CreateRegistrationModel("CareerMember");
        var success = TempData["FormSuccess"] != null;
    }
    
    @if (success) 
    { 
        @* This message will show if RedirectOnSucces is set to false (default) *@
        <p>Registration succeeeded.</p>
    }
    else
    {
        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)
                {
                    for (var i = 0; i < registerModel.MemberProperties.Count; i++)
                    {
                        @Html.LabelFor(m => registerModel.MemberProperties[i].Value, registerModel.MemberProperties[i].Name)
                        @Html.EditorFor(m => registerModel.MemberProperties[i].Value)
                        @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>
        }
    }
  • Anton Oosthuizen 206 posts 486 karma points
    Jan 12, 2015 @ 14:01
    Anton Oosthuizen
    0

    Have you found an answer to your question ?

  • Wayne Kruger 7 posts 28 karma points
    Jan 12, 2015 @ 14:15
    Wayne Kruger
    0

    Unfortunately not :(

    I ended up creating a custom Model class and mapping the form to that and then in the controller I manually mapped each of the Model's properties to the Member Type I created, calling each property by name.

    Not ideal.

  • Ahsinah 18 posts 71 karma points
    Jan 26, 2016 @ 13:30
    Ahsinah
    0

    Hi Wayne,

    I am trying to achieve the same result as you, but i can't seem to get to work. I was wondering if you could share a sample of the code that is working for you.

    Many thanks, Ahsinah

  • Wayne Kruger 7 posts 28 karma points
    Jan 26, 2016 @ 13:59
    Wayne Kruger
    0

    Hi Ahsinah,

    Instead of using the MemberProperties[i] field I created a model with the actual properties I needed, i.e, IDNumber, etc.

    Then on my Controller side I take the Model that gets passed and manually set each using member.SetValue("idNumber", model.IDNumber).

  • Ahsinah 18 posts 71 karma points
    Jan 26, 2016 @ 14:37
    Ahsinah
    0

    Thanks a mile Wayne ! :)

  • Michel Collard 44 posts 264 karma points c-trib
    Jul 08, 2020 @ 09:36
    Michel Collard
    0

    Check the member type settings in Umbraco. Be sure that the property option 'Member can edit' is set to "true"

    In the register snippet it says:

    @* It will only displays properties marked as "Member can edit" on the "Info" tab of the Member Type.*@
    
  • Andrew Camilleri 7 posts 78 karma points
    Nov 29, 2020 @ 15:41
    Andrew Camilleri
    0

    I have a similar issue and mine are marked as true. No luck in making it work out of the box yet.

    [Update] I managed to get it working,

    1. I downloaded the latest version of the source code from github.
    2. I referenced the Umbraco.Web, Umbraco.Core and Umbraco.Examine (the last 2 are needed to build Umbeaco.Web).
    3. I built the solution using the source not the nuget package.
    4. The extra properties are now saved in Umbraco.
Please Sign in or register to post replies

Write your reply to:

Draft