Copied to clipboard

Flag this post as spam?

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


  • Ras 61 posts 324 karma points
    Sep 01, 2022 @ 13:33
    Ras
    0

    Checking boxes in a checkboxlist programmatically

    I have a form where users create an umbraco node with a bunch of data and one of these properties is a checkbox list with the days of the week. As per documentation this is how you're supposed to set the value of checkboxes:

    content.SetValue("superHeros", JsonConvert.SerializeObject(new[] { "Umbraco", "CodeGarden"}));
    

    So an array of strings, simple enough. When I try this I get an error saying:

    'Variation "

    So I figured maybe it will instead accept the indexes of the items in the checkbox list, so I tried passing option 0 and 1, something like this:

    content.SetValue("superHeros", JsonConvert.SerializeObject(new[] { 0, 1}));
    

    But this gives me the same error. Am I misinterpreting the documentation?

  • Ras 61 posts 324 karma points
    Sep 01, 2022 @ 13:43
    Ras
    100

    Quickly answering this one myself, the problem was with culture not being set as well. Just add it to the end like so (only if it varies by culture I assume) and it works:

    content.SetValue("superHeros", JsonConvert.SerializeObject(new[] { "Umbraco", "CodeGarden"}), "sv");
    
Please Sign in or register to post replies

Write your reply to:

Draft