gform_gfcf_custom_empty_field_check

Description

This filter allows other add-ons to add their inputs in Conversational Forms.

Usage

Applies to all forms:

gform.addFilter('gform_gfcf_custom_empty_field_check', function() {
    // Your logic here
});

Parameters

The filter has no parameters.

Examples

Render the filter for the Pipe Add-On.

The pipe field is a hidden input element not counted as a filled field by default when determining whether the form is empty. Adding this filter for the Pipe field will prompt Conversational Forms to verify whether it is filled or empty, ensuring it is included in the form’s validation process.

document.addEventListener('DOMContentLoaded', function() {
    // Custom function to add to the gform_gfcf_custom_empty_field_check filter.
    function customBypassValidations(bypassFunctions) {
        // The pipe field is a hidden input element and, by default, hidden elements
        // aren't counted as filled fields when checking if the form is empty.
        // Adding a filter for the pipe field will force Conversational Forms
        // to check if the field is empty or not.
        bypassFunctions.push([
            // Check if the input is of type pipe_recorder
            function(input) {
                return input.closest('.gfield--input-type-pipe_recorder');
            },
            // Set to false so internally it is not bypassed as a hidden input
            function() {
                return false;
            }
        ]);
        return bypassFunctions;
    }

    // Add filter to the gform object
    if (typeof gform !== 'undefined' && typeof gform.addFilter === 'function') {
        gform.addFilter('gform_gfcf_custom_empty_field_check', customBypassValidations);
    }
});

Placement

Your code snippet can be placed in an HTML field on your form or in a theme custom JavaScript file.

See also the JavaScript/jQuery section in this article: Where Do I Put This Code?

Source Code

This filter is located in /assets/js/src/theme/components/form/validation.js

Since

The filter was added in Conversational Forms 1.5.0