Copied to clipboard

Flag this post as spam?

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


  • marcelh 171 posts 471 karma points
    Mar 20, 2015 @ 19:29
    marcelh
    0

    DropDown List and DropDown List - Publishing keys both return the prevalue

    Am I missing the obvious here, do I interpret the documentation wrong, or have I found a (solved) issue?

    • The DropDown List displays a list of preset values. The value saved is a text value. In the example I expect the actual value to be "Superman".
    • The DropDown List - Publishing keys displays a list of preset values. The value saved is the prevalue id. In the example an int, say 159.

    In my case, using Umbraco 7.1.9 but also in another solution running Umbraco 7.2.2, using these DropDowns the value is either "159" (as a string) or 159 (as an int). But the prevalue, instead of "Superman" and 159.

  • Jeavon Leopold 3074 posts 13631 karma points MVP 11x admin c-trib
    Mar 20, 2015 @ 20:54
    Jeavon Leopold
    0

    Hi,

    I'm sure I totally follow. To ensure you always get a int specify the type, e.g.

    Model.Content.GetPropertyValue<int>("character")
    

    Am I miss understanding you?

    Jeavon

  • marcelh 171 posts 471 karma points
    Mar 20, 2015 @ 22:56
    marcelh
    0

    That's what I understand, Jeavon. But how I read the docs, is that when using the DropDown List - Publishing keyes, saves the prevalue id, 159 in my example. Using the DropDown List saves the text value, "Superman", not the prevalue as a string.

    However, when debugging I notice that both editors to save the prevalue, one as string and one as int.

    Model.Content.GetPropertyValue<string>("character") //returns "159" using the DropDown List
    Model.Content.GetPropertyValue<int>("character") //returns 159 using the DropDown List - Publishing keys
    
  • Jeavon Leopold 3074 posts 13631 karma points MVP 11x admin c-trib
    Mar 20, 2015 @ 23:06
    Jeavon Leopold
    0

    Oh, that's not right, I'll see if I can reproduce!

  • marcelh 171 posts 471 karma points
    Mar 23, 2015 @ 09:20
    marcelh
    0

    Wait, hold your horses! I figured out that in one solution I was not using a IPublishedContent but an IMedia object to get the property from. I needed to manually update a property's value in an event, thus I needed to use the MediaService, returning an IMedia object.

    Using Umbraco.TypedMedia(1234), returns IPublishedContent, I can use GetPropertyValue

  • Jeavon Leopold 3074 posts 13631 karma points MVP 11x admin c-trib
    Mar 23, 2015 @ 16:07
    Jeavon Leopold
    100

    Ah yes, that's expected. Even when using "DropDown List" at the database level it stores the prevalue id, but IPublishedContent resolves it's value before caching unlike "DropDown List - Publishing keys". So when using management API's like IMedia you should be able to get and set the database values.

  • marcelh 171 posts 471 karma points
    Mar 23, 2015 @ 20:28
    marcelh
    0

    And in the other solution I've found that the DropDown List just works as expected as well. Instead of using this DropDown List, I was using a RadioButton List that saves the prevalue ids, not the values.

    How difficult would it be to also create a RadioButton List and a RadioButton List - Publishing keys (which is the current implementation)? Would be nice if that editor would be included by default as well, then all editors have the same publishing behaviour. I noticed that a CheckBox List also saves the selected value, not the prevalue id.

  • Jeavon Leopold 3074 posts 13631 karma points MVP 11x admin c-trib
    Mar 23, 2015 @ 20:51
    Jeavon Leopold
    0

    These editors have been around for a very long time and their names are a bit confusing.

    You are right , "Radiobutton List" should really be called "Radiobutton List - Publishing Keys" as it returns the prevalue id's and "Checkbox List" returns the value only, there isn't a "Checkbox List - Publishing Keys".

    I would suggest looking at nuPickers, you could use the Json or XML data source and point to a file you would need to create with the key/value pairs in it?

  • marcelh 171 posts 471 karma points
    Mar 24, 2015 @ 09:22
    marcelh
    0

    Indeed, and it would be nice if there was a RadioButton List (publishing values) too. A CheckBox List - Publishing Keys would complete the set. On the wishlist, can't be that difficult ;-)

    I took a look at the nuPickers, but I don't want to introduce them into this package, only for the need of a radiobutton list that saves values.

Please Sign in or register to post replies

Write your reply to:

Draft