I have added some custom properties to the default Member Type of Member.
Some of these custom properties are custom Checkbox List data types.
I'm able to successfully create new members and populates these fields.
I now need to create a razor-based Edit Profile page on the website to allow users to update their profile.
How do I create the custom Checkbox List properties on this page?
Members.GetCurrentMemberProfileModel() only returns the selected value for these properties. There is no information regarding the data type that the property belongs to.
Am I going to have to hard-code the data type ids for the custom properties on the Edit Profile page?
This is what I ended up doing, gender and communication method are my custom checkbox lists
Created an EditMemberViewModel:
/// <summary>
/// Edit Member View Model
/// </summary>
public class EditMemberViewModel
{
public ProfileModel Member { get; set; }
public IEnumerable<SelectListItem> Gender { get; set; }
public IEnumerable<SelectListItem> CommunicationMethod { get; set; }
}
I then created a SurfaceController with an EditMember method:
public class AuthSurfaceController : SurfaceController
.... .... .... ...
public ActionResult EditMember()
{
var model = new EditMemberViewModel
{
// This returns the editable fields so doesn't include FirstName, LastName, DateOfBirth or MembershipType
Member = Members.GetCurrentMemberProfileModel(),
};
// Get lookup values
model.Gender = GetPrevalues("Member - Gender - Checkbox list", model.Member.MemberProperties, "gender");
model.CommunicationMethod = GetPrevalues("Member - Communication Method - Checkbox list", model.Member.MemberProperties, "communicationMethod");
return PartialView("Membership/EditMember", model);
}
Then in my EditMember razor view at the top:
var profileModel = Model.Member;
and then further down this snippet of code renders radiobuttons for the custom checkbox fields
Custom checkbox list properties for Members
I have added some custom properties to the default Member Type of Member.
Some of these custom properties are custom Checkbox List data types.
I'm able to successfully create new members and populates these fields.
I now need to create a razor-based Edit Profile page on the website to allow users to update their profile.
How do I create the custom Checkbox List properties on this page?
Members.GetCurrentMemberProfileModel() only returns the selected value for these properties. There is no information regarding the data type that the property belongs to.
Am I going to have to hard-code the data type ids for the custom properties on the Edit Profile page?
I'm having the same issue, cannot find any documentation on this at all.
This is what I ended up doing, gender and communication method are my custom checkbox lists
Created an EditMemberViewModel:
I then created a SurfaceController with an EditMember method:
.... .... .... ...
Then in my EditMember razor view at the top:
and then further down this snippet of code renders radiobuttons for the custom checkbox fields
Hope that helps. Let me know if you need any more info..
Is this example valid for Umbraco 8 - if so, would You care to share a full working example...? :)
is working on a reply...