Access all components in form

Is it possible to get access to all components in a form?

When I apply data bindings I sometimes forget to change the data bindings so that they all point to the same textbox etc.

I would like a way to access them without having to add them to a list of components. The way I think of doing it now is:

self.my_textboxes = [self.my_text_box_nr_1, self.my_text_box_nr2, ....]
self.my_labels = [self.my_label_nr_1, self.my_label_nr2, ....]
self.all_components = [self.my_text_boxes, self.my_labels, ]

But this does not seem so Pythonic? Is there a better way, maybe like self.__components__ or similar?

I can’t find the docs for Forms in the API Reference or the Github code, where are these?

Do you need all components available with form on screen or just the ones inside a single container?

If the latter, you can use component.get_components, but if the former, you would need to iterate over all the containers and then go into nested containers with component.get_components.

1 Like

Thanks, component.get_components solves the issue.

Do you know where I can find the source code/documentation?

1 Like

here ya go: Anvil Docs | Containers

2 Likes