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.


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


  • $cdata_string string

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


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 '<![CDATA[';
add_filter( 'gform_cdata_close', 'my_cdata_close' );
function my_cdata_close() {
    return ']]>';

Source Code

As of Gravity Forms 2.5.8, this filter is located in GFCommon::get_inline_script_tag() inĀ common.php.

This filter was previously 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


Version 1.6.3