Conditional fields not updating
-
Hi team,
I’ve encountered an issue where conditional fields are not being hidden or shown as the user fills out the form. Disabling this plugin makes the conditional statements work again as intended.
In our particular instance, we only need this plugin for our client’s subscription form, as it appears in the footer as well as in the homepage content. Luckily they’re both set up to use ajax, so I created a quick action to enable or disable the
gform_get_form_filter
filter depending on whether the form is ajax or not.add_action( 'gform_register_init_scripts', function( $form, $field_values, $is_ajax ) { $registered = empty( $GLOBALS['gravity_forms_multiple_form_instances_disabled'] ); if ( isset( $GLOBALS['gravity_forms_multiple_form_instances'] ) ) { if ( $registered && ! $is_ajax ) { remove_filter( 'gform_get_form_filter', array( $GLOBALS['gravity_forms_multiple_form_instances'], 'gform_get_form_filter_multiple' ), 10, 2 ); $GLOBALS['gravity_forms_multiple_form_instances_disabled'] = true; } if ( ! $registered && $is_ajax ) { add_filter( 'gform_get_form_filter', array( $GLOBALS['gravity_forms_multiple_form_instances'], 'gform_get_form_filter_multiple' ), 10, 2 ); $GLOBALS['gravity_forms_multiple_form_instances_disabled'] = false; } } }, 10, 3 );
I’m happy for you to use this code as a template where you can create a settings page and allow users to enable this for ajax forms only, but I feel the plugin may need to be adjusted so that conditional statements will continue to function. Alternativey, it may be necessary to create a form setting that can be used to disable this functionality on a form by form basis.
- The topic ‘Conditional fields not updating’ is closed to new replies.