How to build a button that add an element?

Hello everyone,

I wonder how to build a button that when I click on it will add for example an input short answer ?
And I want to do it as many time I want…

Thank you very much for your help :wink:

Interesting question. Im not sure if this would work for how you want to display it but you could have a repeating group that has a short answer input in it and changed the length to be plus 1 with each button press.

Whats the application?

@sam1 thank you for your answer.

The idea is that the user can create a custom document.

For exemple first he want a short text then an image then a long text. Fill all the inputs and save it.

But for another document he wants an image, 2 long text and one short text…

So it is custom not sure your solution will work…

oh cool Id like to do something like this in the future, maybe you could structure your page so you have a repeated array of objects that are the specifications for the section. So in my fantastic drawing that would be a element of the array which is an object with maybe a title and then an input type then you could choose how to display it from there. essentially my drawing would be repeated. I hope that make sense and is somewhat helpful.
image

@sam1 I think I understand what you mean, but how do I display it ? Beacause for example my array will have several objects
[ {element_name : text, value : "Title"},{element_name : input_short, value : ""}
But how I display the element ? I should create and hide by conditionnal rendering XX elements of each type ?

yeah I think that would be the way to go, so there would be multiple inputs in the group that are shown or hidden based on the required input.

1 Like

Hi @Fix !

I think you can create a variable with array of objects and within that object there is a “Type” to know if it is an image or input and all possible input types.

When the user chooses the input type, a workflow must be triggered to hide or show the correct type. on the add button you will need to create a “change variable value” workflow and mark it as “insert at end”.

Also enter the answer of what type of input you want.

On the front, you create a container of repeated items by binding the variable. Inside this container place all types of inputs and on the display you make a conditional for the value of the variable and a Select Input to choose the input type.

Best Regards,

1 Like

@sam1 , @felipegranado thank you for your help, it is working ! :clap: :pray:

CleanShot 2024-03-21 at 15.15.19

2 Likes