I know there are a million threads about this, but sifting through most of them I haven’t been able to find an answer.
This tutorial does a great job of explaining how to dynamically check checkboxes. Which is the function I’m really after here. However, the number of checkboxes are based on a db query.
I can easily generate a bunch of checkboxes based on a query using a repeat children. But that won’t allow me to use the nice feature of dynamically checking them as we can do the multi checkbox form data as explained in the tutorial .
I cheekily tried to place a repeat children inside of the form group which wasn’t allowed.
Any ideas on how to generate a bunch of checkboxes based on a DB query (as you do with a repeat children) but dynamically check them based on if the checkbox’s value exist in a table?
I tried using a dynamic attribute “checked” on the checkbox input itself, but couldn’t figure out how to check if the value existed in a given table. After having tried every single possible combination of data formats on the data binding I was about to flip my desk but found the tutorial linked above.
Perhaps the correct answer here is to NOT bother with the form and use a repeat children as I currently am, but figure out how to use the dynamic attribute if value exist in a given table?
Which will tick the first box “Rockstar” which is has the value of 7. Splendid, so everything seems to be set up correctly as far as getting the basics going. The condition used here will of course only return the first entry in the table.
And this is where I get stuck, I can’t figure out how to compare it against the full list from Table 2. I’ve tried returning a full list using “values” conn_layout_single_talent.data.query.tags.values(talent_tag_id) and a condition checking if that returned list contains the value of the checkbox, and a myriad of other weird combinations in my desperate attempts. But embarrassingly enough I can’t figure out the logic of it.
Unfortunately I don’t think that will work, since the repeat is using Table 1 as data source, in generating the dynamic list of checkboxes.
So it will always return TRUE, since the checkbox’s value is of course the repeated talent_tag_id.
It’s basically just saying “This checkbox with a value of 7 == the value of the data that generated it, which is 7” right? So it ends up comparing against itself.
conn_layout_single_talent as referenced in the snippet you quoted is returning table 2.
Unbelievable. I had tried that before and it didn’t work, tried it again and seeing your example, it turns out that my script had simply somehow got messed up, and looked like this.
At first I wasn’t able to reproduce the first image. Turns out that if you create the “values” and then right click #property, it will give you the contains option. But if you apply it correctly to begin with, like the second image, you’re no longer given the contains option when you right-click on #property.
I’m sure that makes perfect sense… somehow, but it sure befuddled me
Thank you so much @famousmag and @bpj for all your help with this!