offValue as object

Hey @charlie ,

Thanks for adding this in 6.4.5, but is there any documentation on how it works?

There sort of was on offValue, but I expanded on it here and gave you some examples. Have a great day.

Ok, interesting. In my testing, the offValue doesn’t appear until you turn on an option and then turn it off by clicking on the selected option again. I was hoping the offValue would give me an initial object value of sorts.

I’m testing this by instantiating a new component element and seeing what happens on initial load of the component. I tried setting the key value pair of "initial":"offvalue",, but that doesn’t get the job done either. My initial value is still blank.

I can resolve this by setting a fallback= attribute in my dynamic content, which I suppose is fine, but I was hoping to be able to set an initial object value of some kind in my parameters themselves, for readability later.

For reference, here are my parameters:

{
    "cat" : {
      "label": "Category Type",
      "type": "choose",
      "offValue": {
        "color": "#721c99",
        "title": "Choose a Category"
      },
      "options": [
        {
          "value": {
            "color": "#a6380a",
            "title": "Foundations for Victory"
          },
          "label": "Foundations"
        },
        {
          "value": {
            "color": "#f26321",
            "title": "Areas of Restoration"
          },
          "label": "Restoration"
        }
      ]
    },
    "title" : {
      "type" : "text",
      "label" : "Page Title",
      "initial" : "{{dc:post:title}}"
    },
    "bg" : {
      "type" : "image",
      "label" : "Background Image",
      "initial" : "3952:full"
  }
}

Hey @bobbybosler,

The offValue is some sort of a hidden choice when nothing is selected. This is different from the initial value because the initial value acts as the default value of that parameter.

Hope this helps.

Ok, so I guess I didn’t realize that initial and offValue had no overlap.

So, I set up an object in initial, and now when a new component is created, it starts off in breakout mode with [object Object] in the field.

@charlie, is there any way to get an initial with an object as its value to appear as unselected when a new component is instantiated?

Hello @bobbybosler,

Just remove the initial value because the offvalue will be used by the parameter as the default value when nothing is selected.

Thanks.

By “will be,” do you mean in a future release? Because it’s not doing so right now.

Hi @bobbybosler,

It is working on our local test server. I am using your JSON in this video:

If it displays [object object], then it could mean that there is something wrong with the JSON value.

Thanks.

@ruenel,

Ok, so try this. Export that example component, and bring an instance of it into another page. You’ll find that in the new instance of the component that offValue doesn’t populate until you choose one of the options and then un-choose that option. In other words, new instances of an exported component do not receive the offValue.

This is a problem with initial as well for parameters, at least for objects. I knew it was an issue with global theme parameters, but thanks for letting us know this exists for all parameters. Thanks have a great day.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.