Are form variables not visible while the form is in a collection item?

You are right! Thanks a lot! I found a way while you were responding. I did put the variable binded to the initial state of the Rich Text and on click I reset that variable…and itt works :slight_smile:

1 Like

@dorilama Your answer and steps shared here are very helpful, Thanks!
I really wish Weweb documentation can share this easily with others and dive into it further as well.

I’ve implemented what you suggested but since working with arrays/forms within Weweb is a big jump for me (still trying to better understand & learn), I was wondering if you could help me understand the best way to build on this for a pretty general use case (Add repeater items & delete them).

I am displaying a collection of repeated items that share the same structure inside a form as inputs, to allow quick edit. I want to:

  1. Add: create a new repeater row for a user to input something new.
  2. At the same time, I want to create a delete record (this will likely be within the collection item) which would delete the collection item from the form array locally (the variable, because I want all updates to the API to go on click of an update button.

For #1, I was thinking of perhaps pre-populating the added repeater row with template text & then refetch the collection. However, I am not sure if this is the most effective & correct approach. For #2, still trying to get my head around targeting a specific collection item where the button was clicked for removal from the original array.

Thanks again!

The example above is for keeping track of the inputs value. If you start a new topic it’s easier to get answers and ideas from the community.

Managing the data displayed is a different thing.
Generally speaking you bind your container to an array, so to add a new element locally you need to add a new element to the array (with initial values if you need), and to remove an element locally you need to filter it out (usually based on a id) of the array.
Then at some point you want to sync the changes with your backend.

1 Like

@dorilama this was extremely helpful, thank you! I’ve added a submit button to my collection list and im curious how you configure that button dynamically. For example, the button on each row of the collection is updating all rows with the same data in my current setup.

It depends on what backend you use, but you should be able to target the right data with the id.

Related question to this thread.
How can I reset the value of the input. I can track the value through a variable, but how I reset the value of the input once the form is submitted?

I tried binding the value of the input to the same variable but, as expected, is not working though.

If your input is bound to a variable reset/modify the value of the variable. See also this

1 Like