I have an issue with fields that are dynamically added to a form. Fields are added nicely, but the problem is that in the back-end I cannot see the values.
Hi Zoltan. Normally, when using gform_pre_render like that, you also need to use three other filters, to populate those fields in the other locations they are displayed. You may be able to add the filters like this:
add_filter( 'gform_pre_render', 'handle_report_form' );
// Note: when changing choice values, we also need to use the gform_pre_validation so that the new values are available when validating the field.
add_filter( 'gform_pre_validation', 'handle_report_form' );
// Note: when changing choice values, we also need to use the gform_admin_pre_render so that the right values are displayed when editing the entry.
add_filter( 'gform_admin_pre_render', 'handle_report_form' );
// Note: this will allow for the labels to be used during the submission process in case values are enabled
add_filter( 'gform_pre_submission_filter', 'handle_report_form' );
Documentation:
Or, instead of using four filters, you could change from gform_pre_render to gform_form_post_get_meta:
Thanks for all your help Chris, this is almost perfect! The only issue is that when after submitting the form for the first time all the fields get added inside the form back-end. Is this something that can be avoided?