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>
}
}
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.
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.
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:
Have you found an answer to your question ?
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.
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
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).
Thanks a mile Wayne ! :)
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:
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,
is working on a reply...