Pro 6.x No longer possible to use objects as values?

I have been setting up some components and using a simple choose control to do some more complex settings under the hood with array values. The problem I am having is in setting the initial value for this control.

Based on the example put together by @whitemedia, it might once have been working to set the initial value to the label of the choose control. I have also tried setting the initial to an array, similar to the method with the color-pair control type. The first try just sets the value of the choose to the text of the label, and the second works in terms of storing the initial values, but the user sees [object Object] in the control input, instead of it selecting the correct choose option.

Here is my parameter json:

{
  "color" : "color|global-color:primary",
  "border-radius" : {
    "type" : "choose",
    "initial" : {
      "top": "1em",
      "bottom": "0em"
    },
    "options" : [
      { "value" : { "top" : "1em", "bottom" : "0em" }, "label" : "Top" },
      { "value" : { "top" : "0em", "bottom" : "1em" }, "label" : "Bottom" }
    ]
  }
}

I would like the Bottom option to be the default.

By reverting to the choose options (pressing the back arrow), the stored value in _p_local becomes:

{
  "border-radius": {
    "top": "1em",
    "bottom": "0em"
  }
}

And trying to bring the { "top": "1em", "bottom": "0em" } value in as the initial winds up just showing [object Object] in the control input when the component is first inserted.

You know I went from thinking this was an undocumented feature, to this is just working sometimes by happenstance. It really doesn’t work as you have discovered without actively clicking the button.

I think for an object based system to really work. We would need an id field to place into a choice. That way you could change the object, and it wouldn’t initially start in the [object Object] state, which is a JS thing. I will add another request for this fix, would love to handle this as well as Dynamic Content with toggle controls. Have a great weekend!

3 Likes