Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • David Dupont 61 posts 115 karma points
    Sep 08, 2013 @ 09:13
    David Dupont
    0

    Issue during Synchronize on umbraco v6.1.2

    Hi everyone,

    We are testing Umbraco Contour Code first before buying a complete licence and we cannot get our CodeFirst form being synchronize :

     public enum FormPages
        {
            Contact
        }
     
        public enum FormFieldsets
        {
            Details
        }
    
        [Form("Contact Form", 
            FieldIndicationType = FormFieldIndication.MarkMandatoryFields
            )]
        public class ContactForm : FormBase
        {
    
            [Field(FormPages.ContactFormFieldsets.Details, 
                Type = typeof(Textfield) )]
            public string Firstname { getset; }
    
            [Field(FormPages.ContactFormFieldsets.Details, 
                Type = typeof(Textfield),
                Mandatory = true)]
            public string Lastname { getset; }
    
            [Field(FormPages.ContactFormFieldsets.Details, 
                Type = typeof(Textfield),
                Mandatory = false)]
            public string Company { getset; }
    
            [Field(FormPages.ContactFormFieldsets.Details,
                Mandatory = true,
                Regex = @"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*",
                InvalidErrorMessage = @"Invalid email address",
                Tooltip = @"Email address should be like [email protected],")]
            public string Email { getset; }
    
            [Field(FormPages.ContactFormFieldsets.Details, 
                Type = typeof(Textfield),
                Mandatory = false)]
            public string Telephone { getset; }
    
            [Field(FormPages.ContactFormFieldsets.Details,
                Type = typeof(DropDownList),
                Mandatory = true)]
            public string Topic { getset; }
    
            [Field(FormPages.ContactFormFieldsets.Details,
                Type = typeof(Textfield),
                Mandatory = true)]
            public string Message { getset; }
    
    
            public override void Submit()
            {
                umbraco.library.SendMail(
                    Email,
                    "[email protected]",
                    "ISU : New Contact",
                    string.Format("New message from {0} : {1}"Firstname + " " + LastnameMessage),
                    false);
            }
    
        }

    It fails with the following message :

    Server Error in '/' Application.

    Object reference not set to an instance of an object.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


    Stack Trace:

    [NullReferenceException: Object reference not set to an instance of an object.]
       Umbraco.Forms.CodeFirst.FormManager.SynchronizeForm(Type typeForm) in c:\Program Files (x86)\teamcity\buildAgent\work\fdc2f0fcbbcef310\Umbraco.Forms.CodeFirst\FormBuilder\FormManager.cs:426
       Umbraco.Forms.CodeFirst.FormManager.SynchronizeForms() in c:\Program Files (x86)\teamcity\buildAgent\work\fdc2f0fcbbcef310\Umbraco.Forms.CodeFirst\FormBuilder\FormManager.cs:201
       Umbraco.Forms.CodeFirst.FormManager.Synchronize() in c:\Program Files (x86)\teamcity\buildAgent\work\fdc2f0fcbbcef310\Umbraco.Forms.CodeFirst\FormBuilder\FormManager.cs:24
       Umbraco.Forms.CodeFirst.UmbracoManager.Synchronize() in c:\Program Files (x86)\teamcity\buildAgent\work\fdc2f0fcbbcef310\Umbraco.Forms.CodeFirst\UmbracoManager.cs:36
       Umbraco.Forms.CodeFirst.UmbracoManager.SynchronizeIfNotSynchronized() in c:\Program Files (x86)\teamcity\buildAgent\work\fdc2f0fcbbcef310\Umbraco.Forms.CodeFirst\UmbracoManager.cs:21
       Umbraco.Forms.CodeFirst.ContourFormBuilderHttpModule.context_BeginRequest(Object sender, EventArgs e) in c:\Program Files (x86)\teamcity\buildAgent\work\fdc2f0fcbbcef310\Umbraco.Forms.CodeFirst\ContourFormBuilderHttpModule.cs:27
       System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +79
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +164
    



    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18044

    I have tried to update contour with latest nightly build 3.0.15 but got the same message.

    Does someone have ideas about why this error occurs and how I can update My contour version to solve this.

    Regards

    David

     

     

     

  • Comment author was deleted

    Sep 11, 2013 @ 14:42

    Not sure why but will try your example and see if I can reproduce the error and then fix it :)

  • Comment author was deleted

    Sep 11, 2013 @ 14:45

    Can confirm the issue, getting the same YSOD, looking into fix now :)

  • Comment author was deleted

    Sep 11, 2013 @ 14:47

    Ah I see it's because you are using a fieldtype that uses prevalues but aren't supplying any values for it :)

  • Comment author was deleted

    Sep 11, 2013 @ 14:53

    So try

    [Field(FormPages.Contact, FormFieldsets.Details, Type = typeof(DropDownList), Mandatory = true, Prevalues = new[] { "Matt", "Joanne", "Robert" })] public string Topic { get; set; }

    For your Topic field, setting the prevalues

    Prevalues = new[] { "Matt", "Joanne", "Robert" })

  • Comment author was deleted

    Sep 11, 2013 @ 14:54

    Should look nicer now ;)

        [Field(FormPages.Contact, FormFieldsets.Details,
            Type = typeof(DropDownList),
            Mandatory = true,
            Prevalues = new[] { "Matt", "Joanne", "Robert" })]
        public string Topic { get; set; }
    
  • David Dupont 61 posts 115 karma points
    Sep 12, 2013 @ 09:24
    David Dupont
    0

    Hi Tim,

    I finally use :

    [Field(FormPages.ContactFormFieldsets.Details,
            Type = typeof(DropDownList),
            Mandatory = true,
            PrevalueSource = "Contact Form Topics")]
            public string Topic { getset; }

    Since my data source for Topic are Prevalues obtained via XPATH but you definitely solve my issue.

    Thanks

  • Comment author was deleted

    Sep 12, 2013 @ 09:27

    Ah yes you can also set it to use a prevalue source of course :) , glad it's working now!

  • Denford 132 posts 323 karma points
    Aug 11, 2014 @ 19:29
    Denford
    1

    I had same issue but with a radio Button list,

    [Field("signUp", "Details",
            Type = typeof(RadioButtonList),
            Prevalues = new[] { "Bronze", "Silver", "Gold" },
            Caption = "Package")]
        public string Package { get; set; }

    and was missing the pre-values , could help if the error told you which field or object was null but thanks to the above, got it orted now :).

     

Please Sign in or register to post replies

Write your reply to:

Draft