Copied to clipboard

Flag this post as spam?

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


  • Alex Lindgren 159 posts 356 karma points
    Mar 19, 2015 @ 20:06
    Alex Lindgren
    0

    Does Umbraco Forms validation work with strongly typed View Models

    Hi,

    I have another Umbraco Forms question (different from another recent question I posted recently)...

    I am having a problem where validation is not working and I suspect it is because we are using strongly typed view models. I tried adding a SurfaceController that created the View Model for a new doc type with a simple template and it broke. The form will display and submit, but if it is missing required fields it just redisplays with no validation or error messages. Here's what my controller looks like:

    namespace MySite.Controllers
    {
        using System.Web.Mvc;
        using Umbraco.Web;
        using MySite.Content;
        using MySite.Models;
    
        public class FormTestController : ContentMasterController
        {
            public ActionResult Index()
            {
                ArticlePageViewModel model = new ArticlePageViewModel();
                MapBaseProperties(model);
                model.MainContent = CurrentPage.GetPropertyValue<string>("bodyText");
                return CurrentTemplate(model);
            }
        }
    }
    

    Note that the ContentMasterControlller is abstract and extends SurfaceController and is there to share the MapBaseProperties() method which maps some common fields to the model.

    Any one run into similar issues?

    Alex

Please Sign in or register to post replies

Write your reply to:

Draft