Copied to clipboard

Flag this post as spam?

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


  • rakesh 9 posts 88 karma points
    Apr 12, 2017 @ 10:21
    rakesh
    0

    Create A form using Archetype in umbraco

    Hi i want to create a Registration form in umbraco 7.5 version. I created Registration Document Type with template and Created RegistrationController and Registration Surface controller. i was able to show the typedview with model inheriting from Rendermodel.

    In my registration view i have @Html.RenderArchetypePartials(Model.Content.ContentBlocks) and i have archtetype control to render a form.

    When i submit the form i want to show message in view that email already exists. how can i pass the same model which i got from submiting the registration page so that it can show the message and same form again.

    public ActionResult Register(RegistrationFormModel model)
        {
         var memberContext = memberService.GetByEmail(model.Username);
        if (memberContext != null)
            {
                ModelState.AddModelError("Username", "The username/email is already registered.");
                TempData["Error"] = "The entered email address is already registered.";
                return  PartialView("Registration",model);
            }
    //    else do registration
    }
    

    i was able to get page back but model is new
    My registration archetype control has this

    <section class="block-simple">
    <div class="container">
        <div class="block-content">
            <header>
                <h2>
                    <sub>@(Model.GetValue<string>("title"))!</sub>
                    @(Model.GetValue<string>("summary"))
                </h2>
            </header>
            @Html.RenderAction("ArchetypeForm/RegistrationCtrlForm", new  RegistrationFormModel())
        </div>
    </div>
    

    and my Registration Template has this

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage<ContentModels.Registration> 
     @using ContentModels =  Umbraco.Web.PublishedContentModels;
     @using Archetype.Models;
     @using Archetype.Extensions;
     @{
      Layout = "Master.cshtml";
      }
      @Html.RenderArchetypePartials (Model.Content.ContentBlocks)
    

    Can Any one have better idea to do or correction.

Please Sign in or register to post replies

Write your reply to:

Draft