Umbraco 7 Forms Logic Bug
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)))’ />
Leave a Response