Skip to content

Commit

Permalink
#104 - handle missing form property
Browse files Browse the repository at this point in the history
  • Loading branch information
kjac committed Dec 20, 2016
1 parent d8b6f40 commit f9a4eb7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Source/Umbraco/Views/Partials/FormEditor/Async.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -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<FormModel>(formPropertyName);

// #104 - don't break the site if the form model could not be found
if(form == null)
{
@: <!-- no Form Editor form was found on the page -->
return;
}

// attempt to load an existing submission if ViewBag.FormRowId is defined
if(ViewBag.FormRowId is string)
{
Expand Down
7 changes: 7 additions & 0 deletions Source/Umbraco/Views/Partials/FormEditor/NoScript.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
// get the form model
var form = formContent.GetPropertyValue<FormModel>(formPropertyName);

// #104 - don't break the site if the form model could not be found
if(form == null)
{
@: <!-- no Form Editor form was found on the page -->
return;
}

// attempt to load an existing submission if ViewBag.FormRowId is defined
if(ViewBag.FormRowId is string)
{
Expand Down
7 changes: 7 additions & 0 deletions Source/Umbraco/Views/Partials/FormEditor/Sync.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
// get the form model
var form = formContent.GetPropertyValue<FormModel>(formPropertyName);

// #104 - don't break the site if the form model could not be found
if(form == null)
{
@: <!-- no Form Editor form was found on the page -->
return;
}

// attempt to load an existing submission if ViewBag.FormRowId is defined
if(ViewBag.FormRowId is string)
{
Expand Down

0 comments on commit f9a4eb7

Please sign in to comment.