Copied to clipboard

Flag this post as spam?

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


  • Kev 16 posts 67 karma points
    May 01, 2014 @ 18:52
    Kev
    0

    Code first form not showing fields in GUI

    Hi,

    I've been trying to create a basic contact form using the Code First approach. The form appears in the contour interface, but the fields are missing.

    Steps:

    1. Created blank ASP.Net application - c#
    2. Add references
    3. Code below
    4. Build solution
    5. Copy the .dll file to umbraco bin
    6. View form in Umbraco Contour

    Is there something I'm missing? Many thanks in advance.

    The code so far:

    using System;
    using Umbraco.Forms.CodeFirst;
    using Umbraco.Forms.Core;
    using Umbraco.Forms.Core.Providers;
    using Umbraco.Forms.Core.Providers.FieldTypes;
    
        public enum FormPages
        {
            Contact
        }
    
        public enum FormFieldsets
        {
            Details
        }
    
        [Form("Contact", MessageOnSubmit ="Thank you")]
        public class Contact: FormBase
        {
    
            [Field(FormPages.Contact,FormFieldsets.Details,
                Mandatory= true)]
            public string Name { get; set; }
    
            [Field(FormPages.Contact, FormFieldsets.Details,
                Mandatory = true)]
            public string Email { get; set; }
    
            [Field(FormPages.Contact, FormFieldsets.Details,
               Mandatory = true,
               Type = typeof(Umbraco.Forms.Core.Providers.FieldTypes.Textarea))]
            public string Message { get; set; }
    
            public override void Submit()
            {
    
                umbraco.library.SendMail(
                    Email,
                    "[email protected]",
                    "New Contact",
                    string.Format("New message from {0} : {1}", Name, Message),
                    false);
            }
        }
    
Please Sign in or register to post replies

Write your reply to:

Draft