2

I am trying to create a form with Sitecore Forms on 9.3. No matter what I do with the save action I get the following error:

[NullReferenceException: Object reference not set to an instance of an object.]
Sitecore.ExperienceForms.Mvc.Controllers.BaseFormBuilderController.ProcessFormData(FormDataModel data) +66
Sitecore.ExperienceForms.Mvc.Controllers.FormBuilderController.Index(FormDataModel data) +54
lambda_method(Closure , ControllerBase , Object[] ) +138
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +34
System.Web.Mvc.<>c__DisplayClass24_0.<InvokeActionMethodWithFilters>b__0() +79
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +466
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +466
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +524
2
  • can you add your custom save action ? Jan 11 '20 at 17:45
  • This is a bad request. It turns out, the problem was that I minified the forms js files, and that breaks the form. This is extremely frustrating. I cant minify the js?craziness. Jan 11 '20 at 17:57
2

The error you see is happening because the NavigationDataModelBinder which runs before it gets to BaseFormBuilderController.ProcessFormData has not been able to set the NavigationData due to these checks:

  string[] buttonValues = this.GetButtonValues(buttonId, bindingContext);
  if (buttonValues != null && buttonValues.Length <= 1)
    return (NavigationData) null;
  int result1;
  if (!int.TryParse(buttonValues?[1], out result1))
    return (NavigationData) null;

This happens when for some reason the Submit button on the form does not send at least 2 values where the 2nd value is an int.

From the couple of times I've seen this it is because of some javascript that is catching the submit click event and doing event.preventDefault(); or event.stopPropagation(); which prevents the jquery unobstrusive ajax handler from getting the value when serializing it.

So look for things like a document.click() handler that could be interrupting this.

When you say that un-minifying the javascript has helped, then it could be a race condition somewhere. Also check that the form isn't being submitted twice somehow via double event handler registration.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.