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
Update repeating section
Hi everyone,
I'm trying to write a bit of custom code that takes the values from a repeating section when an entry is updated in form A and copy it to an equivalent repeating section in a specific entry in form B.
This is what I've got so far:
add_action('frm_after_update_entry', 'additional_sups', 10, 2);
function additional_sups ( $entry_id, $form_id ) {
if ( $form_id == 97 ) { // Form A
$pref = FrmField::getOne( 2434 );
$pref_value = FrmProEntryMetaHelper::get_post_or_meta_value( $entry_id, $pref, $args );
$pref_b = FrmField::getOne( 1438 );
$project_entry_ids = FrmProEntryMeta::get_entry_ids_for_field_and_value( $pref_b, $pref_value );
$repeating_values = array('form' => "", 'row_ids' => array());
foreach( $_POST['item_meta'][2415] as $k => $r ) {
if ( $k === 'form' ) {
$repeating_values[ $k ] = "96";
} else if ( $k === 'row_ids' ) {
$repeating_values['row_ids'] = $r;
} else if ( is_array( $r ) ) {
foreach ( $r as $i => $v ) {
if ( $i == 2423 ) {
$repeating_values[ $k ][2394] = $v;
} else if ( $i == 2425 ) {
$repeating_values[ $k ][2395] = $v;
} else if ( $i == 3131 ) {
$repeating_values[ $k ][2396] = $v;
} else if ( $i == 3132 ) {
$repeating_values[ $k ][2397] = $v;
}
}
}
}
foreach ( $project_entry_ids as $e ) {
FrmEntryMeta::update_entry_meta( $e, 2392, '', $repeating_values ); //
}
}
}
}
This code works in so far as $repeating_values contains all the correct information and is in the same format as the contents of the field I want to update. But instead of copying across the entire contents of $repeating_values, it copies 'form' but 'row_ids' is blank.
Can anyone spot where I'm going wrong?
Discussion closed.