Changing icon on matrix wdget based on on/off

First of all let me say that this is a great piece of software, thanks for sharing this!

Upon discovering I stumbled on the next problem on which I am trying to get my head around:

I’ve got a 1-10 matrix widget (type toggle) on which I would like to change the label icons based on the on/off state. I managed to get it working with a standalone toggle widget with this code in de label field:

#{
@{this} == 1 ? "^lock" : "^unlock"
}

Now I’m trying to get the same result in a matrix widget. Looked all over the community and I know/think I’ve to use the [$] for finding the matrix index but my attempts are without luck (i’m a newbie in programming…). Can anyone point me in the right direction? Thanks!

looked at this threads:
example 1
example 2

This doesn’t work with a basic matrix because the formula is resolved at the matrix’ scope, not at each subwiget’s own scope (@{this} doesn’t resolve to the button’s value).

To do that you need to create a template widget that behaves as you describe and a matrix of clones widgets that duplicate it . Here is a minimal session showing this : clone-matrix.json (2.0 KB)

Notes:

  • the conditional label code is in the template toggle
  • the $ is used to increment the clone widgets’ ids
  • mind the “props” item in the matrix’ “props” property

Thanks for pointing me in the right direction! Made it to work!