From f9a4eb7d8acebdbc49e5dc65d4eee7419a57d01b Mon Sep 17 00:00:00 2001 From: kjac Date: Tue, 20 Dec 2016 21:41:35 +0100 Subject: [PATCH] #104 - handle missing form property --- Source/Umbraco/Views/Partials/FormEditor/Async.cshtml | 9 ++++++++- Source/Umbraco/Views/Partials/FormEditor/NoScript.cshtml | 7 +++++++ Source/Umbraco/Views/Partials/FormEditor/Sync.cshtml | 7 +++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Source/Umbraco/Views/Partials/FormEditor/Async.cshtml b/Source/Umbraco/Views/Partials/FormEditor/Async.cshtml index e8463be..34c2147 100644 --- a/Source/Umbraco/Views/Partials/FormEditor/Async.cshtml +++ b/Source/Umbraco/Views/Partials/FormEditor/Async.cshtml @@ -10,9 +10,16 @@ // get the name of the form model property on the content type (defaults to "form") var formPropertyName = ViewBag.FormName as string ?? "form"; - // get the form model (named "form" on the content type) + // get the form model var form = formContent.GetPropertyValue(formPropertyName); + // #104 - don't break the site if the form model could not be found + if(form == null) + { + @: + return; + } + // attempt to load an existing submission if ViewBag.FormRowId is defined if(ViewBag.FormRowId is string) { diff --git a/Source/Umbraco/Views/Partials/FormEditor/NoScript.cshtml b/Source/Umbraco/Views/Partials/FormEditor/NoScript.cshtml index 97ab65b..fec7302 100644 --- a/Source/Umbraco/Views/Partials/FormEditor/NoScript.cshtml +++ b/Source/Umbraco/Views/Partials/FormEditor/NoScript.cshtml @@ -10,6 +10,13 @@ // get the form model var form = formContent.GetPropertyValue(formPropertyName); + // #104 - don't break the site if the form model could not be found + if(form == null) + { + @: + return; + } + // attempt to load an existing submission if ViewBag.FormRowId is defined if(ViewBag.FormRowId is string) { diff --git a/Source/Umbraco/Views/Partials/FormEditor/Sync.cshtml b/Source/Umbraco/Views/Partials/FormEditor/Sync.cshtml index f1e67fc..5193f83 100644 --- a/Source/Umbraco/Views/Partials/FormEditor/Sync.cshtml +++ b/Source/Umbraco/Views/Partials/FormEditor/Sync.cshtml @@ -11,6 +11,13 @@ // get the form model var form = formContent.GetPropertyValue(formPropertyName); + // #104 - don't break the site if the form model could not be found + if(form == null) + { + @: + return; + } + // attempt to load an existing submission if ViewBag.FormRowId is defined if(ViewBag.FormRowId is string) {