hi there,
i’m trying to populate a list field with values via php, after form submission.
At this stage my list field is being updated with blank rows only..
can you take a look at my code please?
add_action('gform_after_submission', 'populate_list_field_after_submission', 10, 2);
function populate_list_field_after_submission($entry, $form) {
// Check if the form ID matches the form you want to target
if ($form['id'] == 18) { // Replace 1 with your form ID
// Get the entry ID
$entry_id = $entry['id'];
// Define the list field ID you want to populate
$list_field_id = 1; // Replace 2 with your list field ID
// Define the data you want to populate into the list field
$list_data = array(
array('Column 1', 'Column 2', 'Column 3'), // Replace with your actual column names
array('Value 1', 'Value 2', 'Value 3'), // Replace with your actual values
array('Value 4', 'Value 5', 'Value 6')
);
// Convert the list data to JSON format
$list_data_json = json_encode($list_data);
// Update the entry with the new list field data
GFAPI::update_entry_field($entry_id, $list_field_id, $list_data_json);
}
}