Copied to clipboard

Flag this post as spam?

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


  • Valerie 67 posts 163 karma points
    Jan 29, 2014 @ 18:28
    Valerie
    0

    Umbraco Helper Render Template with Form

    Hi there,

    I have a project where I want to render out "nuggets" on the side of pages, which are chosen via a multipicker. The nuggets have differing shapes and content, so I thought the best way to do this might be to loop over them and call RenderTemplate on them.

    This works perfectly unless I have anything involving a form - on model errors the validation does not fire and any information about the model or viewdata seems to be lost. For example my nugget template is simply this:

    @Html.Partial("_NewsletterForm",new NewsletterModel())

    I call each nugget's template like this on my containing page

    @Html.Raw(umbracoHelper.RenderTemplate(nugget.NodeId))

    However, if I call the partial directly on the container page it works perfectly.

    For reference my controller looks like this:

    public class NewsletterSignupSurfaceController : SurfaceController

        {

            private readonly NewsLetterRepository newsLetterRepository = new NewsLetterRepository();

            [HttpPost]

            public ActionResult CreateSignup(NewsletterModel model)

            {

                if (Request.IsAjaxRequest())

                {

                    newsLetterRepository.Save(model);

                    return Json(true);

                }

                if (!ModelState.IsValid)

                {

                    return CurrentUmbracoPage();

                }

                newsLetterRepository.Save(model);

                TempData.Add("Message", "Your form was successfully submitted");

                return RedirectToCurrentUmbracoPage();

            }

        }

    Is there anything I can do to fix this?

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies