PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Unexpected Token ILLEGAL when adding Section or Page breaks in Edit Form

  1. Having an issue adding section and page breaks to my forms on a client project. Upon clicking the button to add, I get a JS error:

    Uncaught SyntaxError: Unexpected token ILLEGAL

    The AJAX returns this (multi-line) which leads me to believe this is where the issue is with the JS since there are line breaks in it (there are none of these line breaks in responses from adding other field types:

    EndAddField({"id": 33, "label": "Section Break", "adminLabel": "", "type": "section", "isRequired": false, "size": "medium", "errorMessage": "", "inputs": null, "displayOnly": true}, "<li id='field_33' class='selectable gfield  gsection' ><div class='gfield_admin_icons'>
    <div class='gfield_admin_header_title'>Section Break : Field ID 33</div>
    <p><a class='field_delete_icon' id='gfield_delete_33' title='click to delete this field' href='#' onclick='StartDeleteField(this); return false;'>Delete</a><a class='field_duplicate_icon' id='gfield_duplicate_33' title='click to duplicate this field' href='#' onclick='StartDuplicateField(this); return false;'>Duplicate</a><a class='field_edit_icon edit_icon_collapsed' title='click to edit this field'>Edit</a></div>
    <h2 class='gsection_title'>Section Break</h2>
    <div class='gsection_description'></div>
    </li>");

    As I tested further, I saw the same issue with adding HTML fields too. Any thoughts on a solution? Using Chrome + latest WP and GF

    Posted 12 years ago on Sunday January 8, 2012 | Permalink
  2. Tried again on the same site, same thing. Turned no conflict mode on and same thing again. Still digging.. Tried add and edit form, so definitely something fishy.

    Posted 12 years ago on Thursday April 5, 2012 | Permalink
  3. Nevermind, found the issue, and of course it was me. I was filtering on 'gform_field_content', which was being used to filter the output of fields being added into the form editor (weird, but ok), so it broke in two different ways.

    1. It was somehow adding linebreaks, so the JS was invalid.
    2. It was setting autocomplete="off" on all input fields (and removing autocomplete="on"), but it was using double quotes where as the form editor JS is outputting single quote attributes, so the JS was invalid.

    Posted 12 years ago on Thursday April 5, 2012 | Permalink
  4. Thanks for letting us know!

    Posted 12 years ago on Friday April 6, 2012 | Permalink

This topic has been resolved and has been closed to new replies.