Conditional Parameter not working

I am trying to add either an icon or an image control, based on a separate choose control.

However, I cannot seem to get the “when” condition to work. When the when condition below is written, both the icon and image controls disappear.

{
“size” : {
“label” : “Size”,
“type” : “font-size”,
“initial” : “1em”,
“isVar” : true
},
“awards” : {
“type” : “group[]”,
“label” : “Awards”,
“itemLabel” : “{{index}}. {{awardName}}”,
“params” : {
“graphictype” : {
“type” : “choose”,
“label” : “Type”,
“options” : [
{“value” : “image”, “label” : “Image”},
{“value” : “icon”, “label” : “Icon”}
]
},
“graphicicon” : {
“type” : “fa-icon”,
“label” : “Icon”,
“initial” : “award”,
“when” : “eq(graphictype, ‘icon’)”
},
“graphicimg” : {
“type” : “image”,
“label” : “Image”,
“initial” : “”,
“when” : “eq(graphictype, ‘image’)”
},
“awardName” : {
“type” : “textarea”,
“label” : “Award Name”,
“placeholder” : “Best Restaurant Ever”
},
“source” : {
“type” : “source”,
“label” : “Source”,
“placeholder” : “Google”
},
“url” : {
“type” : “text”,
“label” : “URL”,
“placeholder” : “https://www.google.com/review
}
}
}
}

Where am I going wrong?

1 Like

With some rudimentary troubleshooting, including playing with conditions, it seems as though the value of the “choose” is not being passed properly.

@ruenel @nabeel would appreciate your help!

Pretty sure it is a bug. It seems conditions do not work inside parameter lists. I was able to make it work in a group but not in a list.

So if awards must be a list (cause a restaurant can win more than one award i guess), then the only option is to not use conditions currently :confused:

I tested with Cornerstone 6.4.

Since your quotes are all strange in you code above, I paste the code I have tested. So maybe it is easier for support to reproduce.

{
  "awards" : {
    "type"   : "group[]",
    "label"  : "Awards",
    "itemLabel" : "{{index}}.",
    "params" : {
      
      "graphictype" : {
        "type"    : "choose",
        "label"   : "Tag",
        "initial" : "icon",
        "options" : [
          { "value" : "icon", "label" : "Icon" },
          { "value" : "image", "label" : "Image" }
        ]
      },
      
      "graphicicon" : {
        "type" : "fa-icon",
        "label" : "Icon",
        "initial" : "award",
        "when" : "eq($.awards.graphictype, 'icon')"
      },
    
      "graphicimg" : {
      	"type" : "image",
      	"label" : "Image",
      	"initial" : "",
      	"when" : "eq(graphictype, 'image')"
      }
    }
  }
}
2 Likes

Thank you for the notes. I can add better support for conditions. The first condition will work fine after the update. The second will need to be altered to use the path syntax ($.) or follow the same path you used in the first condition. Will need a little more time, but probably finished in a week or two.

      	"when" : "eq($.graphictype, 'image')"

thank you! I assume by “after the update”, you mean 6.4.2?

1 Like

Yes either in 6.4.2 or 6.4.3.

excellent. thank you!

1 Like

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