How to insert a repeating field entry from another form

By: Chad Meinertz | Asked: 11/19/2022
ForumsCategory: Code HelpHow to insert a repeating field entry from another form
Chad Meinertz asked 1 year ago

I thought that this example in the docs would solve my issue but it's not quite what I need...

Form A has a repeating section with a field that stores the id of the entry in Form B that has another repeating field that needs an entry added to it based on the values in Form A.

I've used the frm_after_create_entry hook to capture the fields I need in Form A to create the entry in the repeating field in Form B but I can't seem to figure out how to insert the new entry. 

What function do I need to use and how do I need to format the input so it inserts the row in the repeating field properly?


I've tried 

FrmEntryMeta::add_entry_meta( $reg_entry_id, $repeater_field_id, null, $repeating_values );


FrmEntryMeta::update_entry_meta( $reg_entry_id, $repeater_field_id, null, $repeating_values );

but neither seem to work. The repeating values is an array with the field id/value pairs and I've tried several different formats but nonthing seems to work. Any help would be much appreciated.  

2 Answers
Victor Font answered 1 year ago
Repeaters are actually embedded forms (child forms). See this:
Chad Meinertz replied 1 year ago

<p>Thanks! This helped in building the array that got passed into the add_entry_meta method but when I run it and the Form B already has valus in the repeating section it replaces them and doesn't add to the already existing list. How do I force it to add and not update?</p>

Rob LeVineRob LeVine answered 1 year ago
@Chad Meinertz - if Victor's post doesn't get you where you need to be, let me know. I've done similar stuff several times and it's quite unintuitive, especially when you don't have any framework wrapped around it, such as you have with frm_setup_new_fields_vars, meaning you have to do the whole thing programmatically.
Chad Meinertz replied 1 year ago

@Rob LeVine - I'm still not where I need to be with this. If you have any examples of how to do this that would be much appreciated. My main issue right now is it's not inserting the rows into the repeating section if rows already exist. It's just updating and replacing the existing values.

Rob LeVineRob LeVine replied 1 year ago

Can you send me what you have currently? Feel free to send me a message via the community and we can connect "offline".

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