How to add new component by tapping a button

Hello,
How can I add a new component to the page by tapping a button dynamically using “Add logic”?
Thanks,
Baris

Hi, components have a “Visible” property on the “Advanced” tab that you can use to toggle their visibility. To control this from another component, you can

  1. create a true/false type page variable with initial value false
  2. bind that to the component’s Visible field
  3. then use “Set page variable” to set the page variable to true after “Component tap” of the button

Hi Mari,
Thanks for the prompt answer.
This solution that you are proposing means that any new component should be created while designing the GUI. But the number of components to be created is not known or set in the beginning. So I want to be able to create them in the runtime.
Is this possible in AppGyver?
Thanks,
Baris

Hi, you can for example repeat an arbitrary number of components, but the “base” component has to be created in the editor for it to be able to be created at runtime.

Here’s a thread where there’s an example of repeating n form fields based on user input:

Thanks @Mari I’ll check it.

1 Like