Web Developement
Now Reading
Umbraco 7 Forms Logic Bug
0

Umbraco 7 Forms Logic Bug

by Adrian RandallFebruary 28, 2016

I’ve never had to use conditional logic in Umbraco forms before but as soon as I did, it didn’t work as it looks like there is a Umbraco 7 forms logic bug. It appeared that I’ve setup everything in the backend correctly but I was getting an error saying:

“jquery Unexpected end of input”

Sounds simple enough but took me a little bit of time to find.

In \Views\Partials\Forms\Scripts.cshtml on line 11 these is this line of code:

<input type=”hidden” id=”values_@Model.FormClientId” 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)))” />

It has double quotes wrapping it which breaks the formatting of the HTML and in turn logic or conditional functionality does not work…

Change it to this and you should be good to go:

<input type=”hidden” id=”values_@Model.FormClientId” 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)))’ />

 

 

About The Author
Adrian Randall
I'm a digital marketing specialist, love working on digital business and coding on just about anything. I'm the founder of Arcadian Digital and this site shares some of our knowledge and practices.

Leave a Response