Checkbox checked values from many-to-many table

Hello everyone!

In my web app, I have a products CRUD. The products can have a lot of categories, for this, I created a many-to-many table with category_id and product_id. I was able to record the categories selected (with checkboxes) to the database (thanks for @ben post), but I can’t figure out how to show the selected categories with checked checkboxes on update form.

Any tip?


Hey Otavio,

Use a repeat to display a check box for each of your available categories. On the checkbox use a dynamic attribute - Checked - and select the field from your data that determines if it should be checked or not.


Maybe this will help:

Hey George! Thanks!

I checked this and tried do the same procedures, but instead of using a field with the IDs, a query returning the categories ids of the product, but not worked :frowning:

I tried to create a flow to add the categories retrieved from the database query to a variable or a text input, but couldn’t make it happen…

Hey Ken! Thanks for your reply!

Still not working :frowning:


Checked Dynamic Attribute: I’m using here, a query already loaded by the form, using the product_id as a parameter, only the the products categories are returned.

On “Checked” should I have to compare values? For example: check if checkbox value is == to query returned value?


Somewhere you have stored in the db whether or not each checkbox has been checked. So yes, in the Checked attribute, you need something that will evaluate to true/false.

Hello everyone!

Just found a solution!! I created a custom query and used a MySQL function called GROUP_CONCAT. This function returns rows in columns and you can use SEPARATOR as parameter.

This query:

SELECT GROUP_CONCAT(category_id SEPARATOR ',') as category_id
FROM ProductCategory where product_id = 18;

Returned “3,6,1”. Then, on front end, I used the split method and “checked” dynamic atribute, just like the tutorial @George suggested above.

Thanks for the replies and I hope this can be helpful!