Copied to clipboard

Flag this post as spam?

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


  • Graham Carr 277 posts 389 karma points
    Jul 04, 2014 @ 10:30
    Graham Carr
    0

    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?

  • Brittany McCain 6 posts 26 karma points
    Feb 06, 2015 @ 03:07
    Brittany McCain
    0

    Did you ever solve this? I'm having the same issue.

  • Graham Carr 277 posts 389 karma points
    Feb 06, 2015 @ 09:16
    Graham Carr
    0

    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.

     

Please Sign in or register to post replies

Write your reply to:

Draft