Object reference not set to an instance of an object. (Formulate)
Hi,
Sorry to bother you.
I'm just trying out Formulate on an Umbraco 8.11.1 site, and having followed the instructions finally added the call to render the form.
However, when it tries to render, it errors with the following stack trace:
[NullReferenceException: Object reference not set to an instance of an object.]
formulate.api.Controllers.FormulateRenderingController.Render(ConfiguredFormInfo form) in D:\r\formulate\src\formulate.api\Controllers\FormulateRenderingController.cs:46
lambda_method(Closure , ControllerBase , Object[] ) +104
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
I've boiled it down to the form picker - when I look at the property type for Model.ContactForm, which I'm using as follows:
@Html.Action("Render", "FormulateRendering", new { form = Model.ContactForm })
It tells me that the type is System.String, and that the content is :
formulate.app.Types.ConfiguredFormInfo
Taking at a look at the source in github I can see the type expected is as above. It's almost as if the data picker when I selected the form has taken the type name and stored it as a string in the document.
Any ideas? Would appreciate any help or pointers - I must have missed something or done something stupid during the setup.
Thanks in advance!
Tony
edit #1 : Some extra info for you. If I cast it, I get the following:
formulate.app.Types.ConfiguredFormInfo form = (formulate.app.Types.ConfiguredFormInfo)Model.ContactForm;
Cannot convert type 'string' to 'formulate.app.Types.ConfiguredFormInfo'
Also, I thought I'd check the backend and see what Umbraco believed was stored against the field, and to be honest it 'looks' ok to me:
I'm using the LiveAppData for the models so that the intellisense worked in VS. Looking at the ContactForm model, it has persisted it as an object:
///<summary>
/// Contact Form
///</summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "8.11.1")]
[ImplementPropertyType("contactForm")]
public object ContactForm => this.Value("contactForm");
Thought this might help point out anything obvious to the trained eye.
Edit #2:
Ok getting somewhere now. If I switch to PureLive for the model builder, it's rendering the form fields. So I guess the question now is can I use formulate with the LiveAppData model, or is it only compatible with PureLive?
Thanks for including so much detail with your post; really helps.
Interestingly, I have Formulate (version 3.2.1, which is a bit outdated) working on an Umbraco 8.11.1 site, and I'm using LiveAppData as the ModelsBuilder mode:
The type in my case is also set to be an object for the generated property:
///<summary>
/// Form
///</summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder", "8.1.6")]
[ImplementPropertyType("form")]
public object Form => this.Value("form");
Note that in my case we're using Block List as the property type for widgets, but block list uses doctypes for each widget, so it should be pretty similar to putting a property directly on a doctype for a page.
Here you can see the doctype I have configured for my widget:
I'll try upgrading my install of Formulate to the latest version and try to replicate the issue. Here are some other things to check on:
Be sure you've actually chosen the form. When choosing a form, you really choose a form configuration, which is an object that exists in the tree underneath the form.
Be sure you have the form/form configuration/layout/template all properly chosen.
Check if you have any extra plugins installed (especially any plugins that have custom property value converters).
BTW, how did you check the backend to see what Umbraco believed was stored against the field? Perhaps I can check what is stored on my end as well to see if it looks similar.
I've just upgraded to Formulate 3.5.0 (the latest version) and still haven't been able to reproduce the issue. It's a strange one for sure. Can you try switching back to LiveAppData and see if the issue still exists?
One thought I just had is that the Umbraco variants feature may have some impact on this. My guess is that's why you have a "v" property in your data. Not really sure, but thought I'd mention it just in case it's of use.
Finally had time to look at this again. I noticed I was missing the Umbraco.ModelsBuilder.ModelsDirectory in the web.config file - which to be honest I didn't think would matter.
Regardless I popped it in, rebuilt and generated the models as well as switched back to LiveAppData mode, and it seems to be working now.
Very odd, as the data in cmsContentNu is still the same:
Object reference not set to an instance of an object. (Formulate)
Hi,
Sorry to bother you.
I'm just trying out Formulate on an Umbraco 8.11.1 site, and having followed the instructions finally added the call to render the form.
However, when it tries to render, it errors with the following stack trace:
I've boiled it down to the form picker - when I look at the property type for Model.ContactForm, which I'm using as follows:
It tells me that the type is System.String, and that the content is :
formulate.app.Types.ConfiguredFormInfo
Taking at a look at the source in github I can see the type expected is as above. It's almost as if the data picker when I selected the form has taken the type name and stored it as a string in the document.
Any ideas? Would appreciate any help or pointers - I must have missed something or done something stupid during the setup.
Thanks in advance!
Tony
edit #1 : Some extra info for you. If I cast it, I get the following:
Also, I thought I'd check the backend and see what Umbraco believed was stored against the field, and to be honest it 'looks' ok to me:
I'm using the LiveAppData for the models so that the intellisense worked in VS. Looking at the ContactForm model, it has persisted it as an object:
Thought this might help point out anything obvious to the trained eye.
Edit #2:
Ok getting somewhere now. If I switch to PureLive for the model builder, it's rendering the form fields. So I guess the question now is can I use formulate with the LiveAppData model, or is it only compatible with PureLive?
Cheers!
Thanks for including so much detail with your post; really helps.
Interestingly, I have Formulate (version 3.2.1, which is a bit outdated) working on an Umbraco 8.11.1 site, and I'm using
LiveAppData
as the ModelsBuilder mode:The type in my case is also set to be an object for the generated property:
Note that in my case we're using Block List as the property type for widgets, but block list uses doctypes for each widget, so it should be pretty similar to putting a property directly on a doctype for a page.
Here you can see the doctype I have configured for my widget:
I'll try upgrading my install of Formulate to the latest version and try to replicate the issue. Here are some other things to check on:
BTW, how did you check the backend to see what Umbraco believed was stored against the field? Perhaps I can check what is stored on my end as well to see if it looks similar.
I've just upgraded to Formulate 3.5.0 (the latest version) and still haven't been able to reproduce the issue. It's a strange one for sure. Can you try switching back to
LiveAppData
and see if the issue still exists?I may have one clue. Here's how the form property is stored for me, according to the
cmsContentNu
table:This differs from your example a bit. For examples, your example has an array and a "v" key, while my example does not.
Here the property is within the broader widget context:
There is an even broader page context, but I stripped that out since it didn't seem important.
One thought I just had is that the Umbraco variants feature may have some impact on this. My guess is that's why you have a "v" property in your data. Not really sure, but thought I'd mention it just in case it's of use.
Hi Nicholas,
Thanks so much for the response - sorry I've not replied sooner - work commitments :|
I'll take a look this weekend and get back to you once I've done some tests. Thanks again, it's much appreciated,
Tony
Hi Nicholas,
Finally had time to look at this again. I noticed I was missing the Umbraco.ModelsBuilder.ModelsDirectory in the web.config file - which to be honest I didn't think would matter.
Regardless I popped it in, rebuilt and generated the models as well as switched back to LiveAppData mode, and it seems to be working now.
Very odd, as the data in cmsContentNu is still the same:
It's looking much better now - it's certainly rendering the form properly!
Now onto customising the styles :)
Thanks again, Tony
is working on a reply...