Copied to clipboard

Flag this post as spam?

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


  • Daren Smit 7 posts 87 karma points
    6 days ago
    Daren Smit
    0

    @Html.EditorForModel with a dynamic UmbracoViewPage

    I am trying to generate the inputs for my custom model in my view with: @Html.EditorForModel() like specified in the umbraco documentation. Instead of generating inputs for my variables it generates an input for the CurrentCulture. These are my classes.

    public class ProductModel : RenderModel
    {
        public ProductModel(IPublishedContent content) : base(content)
        {
        }
    
        [Required]
        public string Name { get; set; }
    
        [Required]
        public string Daaaag { get; set; }
    }
    

    This is my cshtml page: https://pastebin.com/g77m4hp1

    This is my controller:

    public class TestController : Umbraco.Web.Mvc.SurfaceController
    {
        // GET: Test
        public ActionResult Index()
        {
            return View();
        }
    
        [HttpPost]
        public ActionResult AddProduct(RenderModel model)
        {
            var productModel = new ProductModel(CurrentPage);
            return null;
        }
    }
    

    So my question is, how would I generate the Inputs for all these variables in my custom model so that when I click the input my ProductModel object has its variables filled with the inputs.

Please Sign in or register to post replies

Write your reply to:

Draft