I'm using this code to loop through the fields:
add_filter( 'ninja_forms_submit_data', function ( $form_data ) {
$form_model = Ninja_Forms()->form( $form_data[ 'id' ] );
foreach( $form_data[ 'fields' ] as $field ){
$field_model = $form_model->get_field( $field[ 'id' ] );
$field_key = $field_model->get_setting( 'key' );
if( 'subject_test' == $field_key ){
$field_model->update_settings( 'value', 'foo' )->save();
}
}
return $form_data;
} );
subject_test is the key of the field I'd like to change the value.
I've tried many other ways to change the value but nothing seems to work.
Can anyone point me out in the right direction?
Got it!
$form_data[ 'fields' ][ $field_id ][ 'value' ] = 'foo';