Copied to clipboard

Flag this post as spam?

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


  • Mark Watson 118 posts 384 karma points
    Oct 16, 2018 @ 03:37
    Mark Watson
    0

    Displaying membership tabs for customer logedin editing

    I am using Umbraco cloud and using the EditMembershipForms.cshtml partial to display the membership details for members to edit. I have created a membership type "active members" and a couple of tabs "Practice details" and "General details". enter image description here

    enter image description here

    Currently the EditMembershipForms.cshtml displays the whole form. How do I display by tab, so just the fields in each tab are displayed for customer editing?

  • Paul Tilsed 26 posts 179 karma points c-trib
    Oct 16, 2018 @ 13:21
    Paul Tilsed
    0

    Hi Mark,

    Its a little unclear how you are writing out the form based on the information you have provided. Would you be able to share more information about the code that's in the view you refer to?

    I'm going to assume that there is some code in there that is looping over all of the properties that have been marked as editable on the Member Type you have defined. I would not expect this to pull in the tabs from Umbraco since they are normally only used for the UI within Umbraco its self. If you want to group the properties then I believe you would have two possible solutions.

    The first is to hand code the form and group the properties manually, this would give you more control over the look of the form. The second option is to pull in the tab information from Umbraco and then use that information to write out the form. Something like the below would be along the path you might need to take.

    @foreach (var propertyGroup in ApplicationContext.Current.Services.MemberTypeService.Get("memberType").PropertyGroups)
    {
        @propertyGroup.Name
    
        foreach (var property in propertyGroup.PropertyTypes)
        {
            @property.Name
            //Form Field
        }
    }
    

    This code snippet is only a basic one to demonstrate how you could retrieve the tab information from Umbraco. In reality it would be a lot more complex I think. One thing to consider is how quickly this code would run as I believe this service would result in calls being made to the database rather than being returned from a local cache.

    Hope this helps,

    Paul

  • Mark Watson 118 posts 384 karma points
    Oct 16, 2018 @ 22:48
    Mark Watson
    0

    Thanks Paul

    I am new to Umbraco and not a coder but stubling my way round.

    This is the code I am using to displays the members editable form.

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    

    @using System.Web.Mvc.Html @using ClientDependency.Core.Mvc @using Umbraco.Web @using Umbraco.Web.Controllers

    @{

    var profileModel = Members.GetCurrentMemberProfileModel();
    
    Html.EnableClientValidation();
    Html.EnableUnobtrusiveJavaScript();
    Html.RequiresJs("/umbraco_client/ui/jquery.js");
    Html.RequiresJs("/umbraco_client/Application/JQuery/jquery.validate.min.js");
    Html.RequiresJs("/umbraco_client/Application/JQuery/jquery.validate.unobtrusive.min.js");
    
    var success = TempData["ProfileUpdateSuccess"] != null;
    

    }

    @if (Members.IsLoggedIn() && profileModel != null)

    {
    if (success) {

        <p>Profile updated</p>
    }
    
    using (Html.BeginUmbracoForm<UmbProfileController>("HandleUpdateProfile"))
    
    {
    
        <fieldset>
    
            <legend>Edit profile</legend>
    
            @Html.ValidationSummary("profileModel", true)
    
            @Html.LabelFor(m => profileModel.Name)
    
            @Html.TextBoxFor(m => profileModel.Name)
    
            @Html.ValidationMessageFor(m => profileModel.Name)
    
            <br />
    
            @Html.LabelFor(m => profileModel.Email)
    
            @Html.TextBoxFor(m => profileModel.Email)
    
            @Html.ValidationMessageFor(m => profileModel.Email)
    
            <br />
    
    
    
            @for (var i = 0; i < profileModel.MemberProperties.Count; i++)
    
            {
    
                @Html.LabelFor(m => profileModel.MemberProperties[i].Value, profileModel.MemberProperties[i].Name)
    
    
                @Html.EditorFor(m => profileModel.MemberProperties[i].Value)
    
                @Html.HiddenFor(m => profileModel.MemberProperties[i].Alias)
    
            }
    
                <br />
    
    
            <button>Save</button>
    
        </fieldset>
    
    }       
    

    }

    Any help would be much appreciated.

Please Sign in or register to post replies

Write your reply to:

Draft