The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group
Repeatable Section & For Each
Hello,
I am looking into another approach, using the copy data to a second table in MySQL as follows:
add_action('frm_after_create_entry', 'wp_frm_tasks', 20, 2);add_action('frm_after_create_entry', 'wp_frm_tasks', 20, 2);function wp_frm_tasks($entry_id, $form_id){ if($form_id == 14){ //change 4 to the form id of the form to copy global $wpdb; $values = array( 'user_id' => $_POST['item_meta'][1140], 'user_id_fe' => $_POST['item_meta'][230], 'profile_start_date_fe' => $_POST['item_meta'][1139], 'display_name_fe' => $_POST['item_meta'][1196], 'email_fe' => $_POST['item_meta'][1197], 'establishment_fe' => $_POST['item_meta'][473], 'rank_fe' => $_POST['item_meta'][474], 'task_name_fe' => $_POST['item_meta'][233], 'flexibility_fe' => $_POST['item_meta'][248], 'task_type_fe' => $_POST['item_meta'][247], 'entry_count_fe' => $_POST['item_meta'][1195],); //replace 25 and 26 with the field ids of the Formidable form. Change col_name to the column names in your table $wpdb->insert('wp_frm_tasks', $values); //change table_name to your table name }}
This works well when not using repeatable sections, am i missing something to why when i use a repeatable section in a form this does not work?
Obviously using the repeatable section in a form there can be multiple entries that require inserting into the new table. ( possible a foreach statement )
Thanks Chris
September 11, 2017 at 12:21 pm
When you have a repeatable section, the field names have 3 dimensions. Instead of $_POST['item_meta'][1195], you have to account for $_POST['item_meta'][section][row][field_id]. I have not examined the actual $_POST variable contents in PHP, but if you use a debugging tool like Kint, you'll be able to view the contents of the variable as passed to the frm_after_create_entry action. You may also be able to view the values of the $_POST variable in the network tab of your browser's inspect tool.
Discussion closed.