Create entry in form with required repeater field via API

By: Jane Onorati | Asked: 09/01/2024
ForumsCategory: General questionsCreate entry in form with required repeater field via API
Jane OnoratiJane Onorati asked 2 weeks ago
I have a form with a source repeater and an API action that creates a new entry in another form that has the target repeater.  This works fine unless I make the field in the target repeater a required field.  Then the API action fails with a 409 error and message in the log: "field691-689-": "Repeater Text cannot be blank."  However, I am sending a value to this repeater field. This is in Formidable's knowledge base on API formatting for repeaters:
  • "":"" = A necessary row of dummy data so that the API request is formatted correctly. Note: If you are sending to required fields inside the receiving repeater, you will either need to modify this row to send dummy data to the actual fields inside the repeater, or mark the receiving fields as not required.
This seems to indicate I need to add something more than just the dummy row "":"" to my API action, but I there is no example to help me know what to do exactly.  Does anyone have a solution for this?  Why would I need to send dummy data to the repeater when I'm sending actual data to it?  This is the part of my API action for the repeater: "limj8": {
[foreach vtyb0]
"[id]":{
"691": "[ao4gr]"
},
[/foreach vtyb0]
"":""
},
3 Answers
Victor Font answered 2 weeks ago
You're code doesn't look correct. Did you follow this example? https://formidableforms.com/knowledgebase/formidable-api/#kb-add-values-in-a-repeater
Jane OnoratiJane Onorati answered 2 weeks ago

Hi Victor, yes and it works fine except when the target repeater has required fields in it. I see I missed pasting in the last two lines in the code."form_id": "member-profile"
}It's the same as the example basically, except I'm using keys instead of IDs where Formidable does not say they are not allowed.  I decided to submit a ticket to Formidable and they said they are giving it to their development team to look at.

Victor Font replied 2 weeks ago

Let us know how this turns out. You may have uncovered a bug if it's going to the devs.

Jane OnoratiJane Onorati answered 1 week ago

So I got the fix!  Formidable support gave me a pre-release version of Formidable Pro and a slightly altered syntax to use.  The dummy row, along with the comma before the closing tag of the foreach shortcode, has been removed.

{   "8ij302": "Yes",
    "x0jq42": "[x0jq4]",
    "tybx": "[tybx2]",
    "3vudx": "[1fg4y show=value]",
    "limj8": {
       [foreach vtyb0 sep=","]
       "[id]":{
       "691": "[ao4gr]"
}
       [/foreach vtyb0]
    },
    "form_id": "23"
}

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
crossarrow-right