Hey,
I’m using WordPress as a headless CMS and I’m submitting forms using the Gravity Forms API. I have a form with a repeater field where people can invite up to 3 friends/families.
My problem is that I just can’t seem to make form submissions work for the repeater field. Every other form that does not include repeater fields I can make submission successfully.
This is how I’ve created my repeater fields:
function setup_form_fields($form) {
$email = GF_Fields::create(array(
'type' => 'email',
'id' => 1001,
'formId' => $form['id'],
'isRequired' => true,
'label' => __('Email Address receiver'),
'pageNumber' => 1,
));
$name = GF_Fields::create(array(
'type' => 'text',
'id' => 1002,
'formId' => $form['id'],
'isRequired' => true,
'label' => __('Name receiver'),
'pageNumber' => 1,
));
$invitees = GF_Fields::create(array(
'type' => 'repeater',
'description' => '',
'id' => 1000,
'formId' => $form['id'],
'label' => '',
'addButtonText' => '<span class="fa fa-plus"></span>',
'removeButtonText' => '<span class="fa fa-times"></span>',
'maxItems' => 3,
'pageNumber' => 1,
'fields' => array($name, $email),
));
$sender_name = GF_Fields::create(array(
'type' => 'text',
'id' => 1003,
'formId' => $form['id'],
'isRequired' => true,
'label' => __('Your name'),
'pageNumber' => 1,
));
$form['fields'][] = $invitees;
$form['fields'][] = $sender_name;
return $form;
}
I can’t find any example of a repeater field request body. So my question is just how should my request body look like for the repeater field values? I’m using application/json
as content-type.
The 400 response I receive is also not really helpful as it does not include any messages:
{
"is_valid": false,
"validation_messages": {
"1000": ""
},
"page_number": 1,
"source_page_number": 1
}