Handling of Repeater via REST API (javascript HTTP)

By: Roland Wiedemeyer | Asked: 03/09/2023
ForumsCategory: Code SnippetsHandling of Repeater via REST API (javascript HTTP)
Roland Wiedemeyer asked 1 year ago
I have an existing Form and have added a repeater.
Some Firlds which are part of the master form should be moved into the repeater area.
To give you an understanding:
The Form has fields which are general descriptions.
These desription shall be displayed in different languages.
The repearter keeps the different Languages.
The first original language field (4 RTF fields ) shoud be moved into the repeater.
In the API documentaion is one example which handle the copying from one form to another.
In my situation i have to copy fro inside the master form into the repeater.
My question: how to setup the POST/PATCH REST command to copy the field?
Any hint is aprreciated (formID of the repeater is known).

WP Version: 5.9.2
Formidable Version: 5.5.6

Customer Status: elite
Email: [email protected]
How can we help?: I need help with an add-on
Select a Category: Formidable API
Select a sub-category: Other
Have you checked the available categories and subcategories and have selected the most applicable category?: Yes, and I have visited the linked documentation pages.
What category do you feel BEST fits your question?: How to handle Repeater with REST
Add-on Version: 1.13
User ID: Roland Wiedemeyer gmbh
User agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36
IP Address: 2003:f2:bf17:ce5c:65dc:2714:e641:b9f7
User-Agent (Browser/OS): Google Chrome / Windows
Referrer: https://formidableforms.com/new-topic/?&frm_page=2

Tickets this month: 1
Tickets past 6 months: 3
2 Answers
Victor Font answered 1 year ago
If all you're doing is adding content to a repeater field that's in the same form as the description fields, I would not use an PUT/PATCH API call that requires the form entry to be submitted and saved first. API calls require the data to exist in the database before you can edit it. This means the form needs to be submitted first. I prefer to handle requirements like this in real time with jQuery, but because repeaters are Ajax based, there are some complexities to address when doing it this way. See this for details: https://formidable-masterminds.com/repeaters-and-complex-jquery-operations/
Roland Wiedemeyer answered 1 year ago
Hi Victor,
in my master form i have around 1000 entries which have to be modified, so that the entries existing up to now, have the opportunity to enter data in a Repeater. The Purpse is: To give the users the chance to create Company descriptions in different languages.
The original single language was german and now we want present the information on a multilanguage site. WPML helpd me to prepare pages an views in up to 4 different languages. But the data itself has to be translated. My approch is, to put the fields which contain language sensitive data into a repeater.
I don't see a different coice, than to do it via scripting.
I select a set of data though specific views.
inside the view is a javascript call. In a codesnippet the data will be manipulated. Field copying and than the PUT statement which modifies the original dataset+the Repeater fields. The good point is: I have to enter only one repeater record.
What i found out is, i have to run a "kind of create script" (in reality an update to the Master) and after that an update process, which the can cpoy the fieldcontent. After that everything will be displayed basically correct (only one dropdown is not set correct). But I'm finally not sure if this is the right way. My update data which is sent via ajax is like this: (masterform is 84, repeater is 121, record.id is the specific master record ID, fvz_rpt_sprachen is the key of the repeater container) var upddata = {"form": 121};
"fvz_rpt_sprachauswahl": "deutsch",
// "fvz_rpt_sprachauswahl-value": "de",
"fvz_rpt_firmenbes": record["fvz_firmenbes"], 
"fvz_rpt_firmazuecg": record["fvz_firmazuecg"] }; // for any reason, the fields are not set in the first run
upddata = { "fvz_rpt_sprachen": upddata }; Any idea how it can be done in a single step?
Or is it neccesary to do it in 2 steps?  
Victor Font replied 1 year ago

Formidable does not include empty fields when form entries are saved. If you want to update a field that was empty at form submission, you have to add it to the frm_entry_metas table first, then you can update it.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community