Copied to clipboard

Flag this post as spam?

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


  • Christina 127 posts 390 karma points notactivated
    Nov 01, 2018 @ 20:39
    Christina
    0

    Update children with surfacecontroller and BeginUmbracoForm

    Hi I need som help I want to edit a list of childpages with a BeginUmbracoForm and surfacecontroller directly on a page with an edit view to a surfacecontroller But I cant figure out how to do a list in the surfacecontroller (the list is populated from backoffice but i want to make it editable on frontend)

     public class SkistatusFormController : SurfaceController
    {
        // GET: SkiStatusForm
        [ChildActionOnly]
        public ActionResult Render(Skistatus model )
        {
            List<SkistatusFormModel> SkistatusViewModel = new List<SkistatusFormModel>();
            foreach (var item in model.Children)
            {
                SkistatusViewModel.Add(new SkistatusFormModel{Name = model.Name.ToString(),IsOpen = model.IsOpen});
            }
    
    
            return PartialView("~/Views/Partials/SiteLayout/SkistatusForm.cshtml", SkistatusViewModel);
    
        }
    }
    

    My models

    public class SkistatusFormModel
    {
        public string Name { get; set; }
        public bool IsOpen { get; set; }
    
    }
    

    and a list

       public class SkistatusViewModel
        {
            public List<Skistatus> Items { get; set; }
        }
    

    Many thanks /Christina

Please Sign in or register to post replies

Write your reply to:

Draft