How to render custom member properties, Umbraco 7.
Hi,
I'm trying to create some custom properties for members and allow the members to edit them on the front end via a form in umbraco 7.
I've created the properties in the back office in Members -> Member types -> Generic properties.
Im now struggling to find out how to show the properties to the member and allow them to edit and save them.
There seems to be a lot of very different advice from various versions of umbraco but i cant seem to find a definitive answer for umbraco 7. Could anyone tell me what the best way to accomplish this is?
var profileModel = Members.GetCurrentMemberProfileModel();
...
for (var i = 0; i < profileModel.MemberProperties.Count; i++)
{
@Html.LabelFor(m => profileModel.MemberProperties[i].Value, profileModel.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 => profileModel.MemberProperties[i].Value, "MyEditor")
*@
@Html.TextBoxFor(m => profileModel.MemberProperties[i].Value, new { @class = "form-control"})
@Html.HiddenFor(m => profileModel.MemberProperties[i].Alias)
}
How to render custom member properties, Umbraco 7.
Hi,
I'm trying to create some custom properties for members and allow the members to edit them on the front end via a form in umbraco 7.
I've created the properties in the back office in Members -> Member types -> Generic properties.
Im now struggling to find out how to show the properties to the member and allow them to edit and save them.
There seems to be a lot of very different advice from various versions of umbraco but i cant seem to find a definitive answer for umbraco 7. Could anyone tell me what the best way to accomplish this is?
Cheers, Jonny.
Hi Jonathan,
You will have to call GetCurrentMemberProfileModel to get the properties.
Here's a snippet I've wrote before:
is working on a reply...