I am trying to set some custom member properties for a registration form and this is working perfectly when the member property is a string. However I also have some custom member properties which are drodpdown fields such as Title and Status. I am trying to set the value of these as follows:
However the value is not set, well at least in that if I then view the member that has been created in the administration area then the value associated is not selected within the dropdown property.
Does anyone have any ideas as to what the issue may be or does this have to be done via some different method?
I did manage to resolve this in end. What I did was to utilise the Umbraco Dictionary Dropdown component (https://github.com/leekelleher/umbraco-dictionary-dropdown) and then setup some custom data types utilising this component. What I then did was to set the Key and Value of each dictionary dropdown item to be the same as each other.
The reason you are experiencing the issue is (assuming you are using the build in drop downs property editors) the stored value is actually the prevalue ID of the entry you need to save, not the text. You can get the prevalues using the API and loop through them, but it would require you to hard code the Data Type ID somewhere to be able to look them up. The dictionary dropdown component however allows you to set the Key AND Value of the dropdown, rather than just the Key which the built in one does. With this one, you can pass in the string value, rather than needing to know the prevalue IDs.
You will then find that that (for example) the member.SetValue("title","Mr") will work just fine.
Dropdown Custom Member Properties
I am trying to set some custom member properties for a registration form and this is working perfectly when the member property is a string. However I also have some custom member properties which are drodpdown fields such as Title and Status. I am trying to set the value of these as follows:
member.SetValue("title", "Mr");
member.SetValue("status", "Awaiting Approval");
However the value is not set, well at least in that if I then view the member that has been created in the administration area then the value associated is not selected within the dropdown property.
Does anyone have any ideas as to what the issue may be or does this have to be done via some different method?
Did you ever solve this? I'm having the same issue.
I did manage to resolve this in end. What I did was to utilise the Umbraco Dictionary Dropdown component (https://github.com/leekelleher/umbraco-dictionary-dropdown) and then setup some custom data types utilising this component. What I then did was to set the Key and Value of each dictionary dropdown item to be the same as each other.
The reason you are experiencing the issue is (assuming you are using the build in drop downs property editors) the stored value is actually the prevalue ID of the entry you need to save, not the text. You can get the prevalues using the API and loop through them, but it would require you to hard code the Data Type ID somewhere to be able to look them up. The dictionary dropdown component however allows you to set the Key AND Value of the dropdown, rather than just the Key which the built in one does. With this one, you can pass in the string value, rather than needing to know the prevalue IDs.
You will then find that that (for example) the member.SetValue("title","Mr") will work just fine.
is working on a reply...