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
@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:
- Add: create a new repeater row for a user to input something new.
- 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.
@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
Hi @dorilama!
Thanks for posting this HOWTO.
I’ve been trying to follow it. However, I don’t seem to have access to the “item” tab when binding a value (see screenshot).
I’m sure this is something simple, but it is also eluding me. I’m new to WeWeb so I’m still learning how to use the UI. Particularly, when new options show up based on context is something not obvious to me at the moment.
Wondering if you can illuminate the path for me, or if anyone else here can!
Thanks!
the tab with the context shows up if the element is inside a container(or list, column ecc) bound to an array of data. If you don’t see it it’s probably because your element is outside the container of if the container it’s not bound to an array.
If you checked and both the requirements are met but you still miss the tab you may want to start another topic with more information (for example screenshots of the layout of elements) so that it will be easier for the community to see the problem and suggest a solution
Hi @dorilama thanks for outlining this, it makes a lot of sense.
The challenge I’m having is referencing any value other than the actual id of the one I have changed.
I only have the option to select ‘143’ (see screenshot), which means when I save to my database, it always updates to the 143 value, regardless of the id of the value I’m updating.
How can I get it so I can reference the ID dynamically?
can you provide more details on your issue? Like the whole setup.
Now it looks like that you’re referencing hardcoded value, so it’s not updating. The general thought here is to place your data into “repeated items” element, so you can dynamically reference all the IDs in your data array.