I have built a repeater field to collect two text inputs, two dates and a number, but the fields are not in the entries, nor are they in the email submission, any help would be appreciated.
add_filter('gform_form_post_get_meta_1', 'add_my_field');
function add_my_field($form)
{
// Create a Single Line text field for the projects name
$projectName = GF_Fields::create(array(
'type' => 'text',
'id' => 500, // The Field ID must be unique on the form
'formId' => $form['1'],
'label' => 'Project Name',
'pageNumber' => 1, // Ensure this is correct
));
// Create a Single Line text field for the projects name
$client = GF_Fields::create(array(
'type' => 'text',
'id' => 501, // The Field ID must be unique on the form
'formId' => $form['1'],
'label' => 'Client',
'pageNumber' => 1, // Ensure this is correct
));
// Create a Start Date field for the projects name
$dateStart = GF_Fields::create(array(
'type' => 'date',
'id' => 502, // The Field ID must be unique on the form
'formId' => $form['1'],
'label' => 'Contract Start Date',
'placeholder' => '(DD/MM/YYYY)',
'pageNumber' => 1, // Ensure this is correct
));
// Create an End Date field for the projects name
$dateEnd = GF_Fields::create(array(
'type' => 'date',
'id' => 503, // The Field ID must be unique on the form
'formId' => $form['1'],
'label' => 'Contract End Date',
'placeholder' => '(DD/MM/YYYY)',
'pageNumber' => 1, // Ensure this is correct
));
// Create a Single Line number field for the projects name
$subContractCost = GF_Fields::create(array(
'type' => 'number',
'numberFormat' => 'currency',
'id' => 504, // The Field ID must be unique on the form
'formId' => $form['1'],
'label' => 'Subcontract Cost (£)',
'pageNumber' => 1, // Ensure this is correct
));
// Create a repeater projects.
$projects = GF_Fields::create(array(
'label' => 'Extra Projects',
'type' => 'repeater',
'id' => 505, // The Field ID must be unique on the form
'formId' => $form['1'],
'addButtonText' => '+ Add Project', // Optional
'removeButtonText' => '- Remove Project', // Optional
'maxItems' => 3, // Optional
'pageNumber' => 1, // Ensure this is correct
'fields' => array($projectName, $client, $dateStart, $dateEnd, $subContractCost), // Add the fields here.
));
$form['fields'][] = $projects;
array_splice($form['fields'], 60, 0, array($projects));
return $form;
}
// Remove the field before the form is saved. Adjust your form ID
add_filter('gform_form_update_meta_1', 'remove_my_field', 10, 3);
function remove_my_field($form_meta, $form_id, $meta_name)
{
if ($meta_name == 'display_meta') {
// Remove the Repeater field: ID 505
$form_meta['fields'] = wp_list_filter($form_meta['fields'], array('id' => 505), 'NOT');
}
return $form_meta;
}
*/
// Hide progress bar on first form page
add_filter('gform_progress_bar', 'hide_progress_bar_wrap', 10, 3);
function hide_progress_bar_wrap($progress_bar, $form, $confirmation_message)
{
$progress_bar = '<span class="wrap_progress_bar" style="visibility:hidden;display:none">' . $progress_bar . '</span>';
return $progress_bar;
}