bookmark_bordergform_cdata_open

Description

These filters provide the ability to validate your forms with XHTML doctypes by allowing you to wrap the javascript output with the form in CDATA blocks.

Be aware. Using this function in conjunction with advanced form javascript will cause issues due to an issue with how WordPress handles CDATA tags.

Usage

add_filter( 'gform_cdata_open', 'my_cdata_open' );
add_filter( 'gform_cdata_close', 'my_cdata_close' );

Parameters

  • $cdata_string string

    Empty by default. Return an opening or closing CDATA block respectively.

Examples

This example demonstrates how to wrap your form javascript in CDATA blocks.

add_filter( 'gform_cdata_open', 'my_cdata_open' );
function my_cdata_open() {
    return '<!&#91;CDATA&#91;';
}
add_filter( 'gform_cdata_close', 'my_cdata_close' );
function my_cdata_close() {
    return '&#93;&#93;>';
}

Source Code

This filter is located in the following methods:

  • GFFormDisplay::get_form() in form_display.php
  • GFFormDisplay::footer_init_scripts() in form_display.php
  • GFFormDisplay::get_js_redirect_confirmation() in form_display.php
  • GFFormDisplay::get_form_init_scripts() in form_display.php
  • GF_Field_CAPTCHA::get_field_input() in includes/fields/class-gf-field-captcha.php