Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Bo Jacobsen 604 posts 2402 karma points
    Jan 06, 2016 @ 12:06
    Bo Jacobsen
    0

    Forms SyntaxError: JSON.parse: end of data while reading object contents at line 1 column 2 of the JSON data

    Using UmbracoForms.Package.4.1.4 & Umbraco version 7.3.3.

    I get this error on all the forms on the site

    SyntaxError: JSON.parse: end of data while reading object contents at line 1 column 2 of the JSON data

        // Calling form this way.
        if (CurrentPage.HasValue("formGuid"))
        {
            Umbraco.RenderMacro("FormsRenderForm", new { FormGuid = @CurrentPage.formGuid })
        }
    
    // script rendered by Umbraco Form
    (function ($, formId, formName) {
        var contourFieldValues,
    
        This line --> recordValues = JSON.parse($("#values_" + formId).val()),
    
        fsConditions = JSON.parse($("#fsConditions_" + formId).val()),
        fieldConditions = JSON.parse($("#fieldConditions_" + formId).val()),
        form = $("#contour_form_" + formName);
    

    Is there a fix to this?

  • Michael Sims 119 posts 387 karma points
    Jan 07, 2016 @ 17:00
    Michael Sims
    0

    Just an additional note - it seems that this only occurs if values (e.g. dropdowns) are included and the value appears to contain an open "{" without a closing one like fieldconditions has

  • Michael Sims 119 posts 387 karma points
    Jan 07, 2016 @ 17:37
    Michael Sims
    101

    It looks like this is a reported issue the fix is to change a line of code in one of the views:

    In the backoffice Settings > Partial Views > Forms > Scripts (or Views > Partials > Scripts.cshtml in Visual Studio), line 10, change the line to the following:

    <input type="hidden" id="[email protected]" value='@Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model.Pages.SelectMany(p => p.Fieldsets).SelectMany(fs => fs.Containers).SelectMany(c => c.Fields).ToDictionary(f => f.Id, f => f.Value)))' />
    

    Basically single quotes not double for the value attribute.

  • Bo Jacobsen 604 posts 2402 karma points
    Jan 19, 2016 @ 14:45
    Bo Jacobsen
    0

    Sorry for the late reply.

    It worked.

    Views -> Partials -> Forms -> Script.cshtml

    Thank you very much Michael.

Please Sign in or register to post replies

Write your reply to:

Draft