Try our conversational search powered by Generative AI!

blog post submit- approval process

Vote:
 

I'm a beginner in episerver. I created a custom form which on submit, has to create a page(same as formpage type) dynamically and  pass the property values to that page.

This page is saved with ready to publish status, so that epi admin can publish it from epi backend. 

Please, suggest me how to associate the form property values to the newly created page.

VIEW:

@model PageViewModel

@{ Layout = "~/Views/Shared/Layouts/_Root.cshtml"; }


@using (Html.BeginForm("Submit", "BlogPage", FormMethod.Post, Model))
{



@Html.LabelFor(m => m.CurrentPage.ListingTitle)
@Html.TextBoxFor(m => m.CurrentPage.ListingTitle)


@Html.LabelFor(m => m.CurrentPage.Brief)
@Html.TextAreaFor(m => m.CurrentPage.Brief)


@Html.LabelFor(m => m.CurrentPage.Title)
@Html.TextBoxFor(m => m.CurrentPage.Title)


@Html.LabelFor(m => m.CurrentPage.Description)
@Html.TextAreaFor(m => m.CurrentPage.Description)


@Html.LabelFor(m => m.CurrentPage.AuthorName)
@Html.TextBoxFor(m => m.CurrentPage.AuthorName)



CONTROLLER:

public ActionResult Index(BlogPage currentPage)
{
var model = PageViewModel.Create(currentPage);
return View(model);
}

[HttpPost]
public ActionResult Submit(BlogPage currentPage)
{
PageReference parent = PageReference.StartPage;
IContentRepository contentRepository = ServiceLocator.Current.GetInstance();
IContentTypeRepository contentTypeRepository = ServiceLocator.Current.GetInstance();
BlogPage blog = contentRepository.GetDefault(parent);
blog.Name ="currentPage.Title";
blog.AuthorName = "currentPage.AuthorName";
blog.Brief = currentPage.Brief;
contentRepository.Save(blog, EPiServer.DataAccess.SaveAction.CheckIn);
return Content("ThankYou");
}

In the httppost, current page properties are null!.Please do guide me ! 

#197434
Oct 03, 2018 4:34
Vote:
 

Vanmathy,
Which version of Forms are you using?

#197471
Oct 03, 2018 18:25
Vote:
 

Vanmathy,
Which version of Forms are you using?

#197472
Oct 03, 2018 18:25
Vote:
 

Vanmathy,
Which version of Forms are you using?

#197473
Oct 03, 2018 18:25
Vote:
 

Vanmathy,
Which version of Forms are you using?

#197474
Oct 03, 2018 18:25
Vote:
 
#197475
Oct 03, 2018 18:33
Vote:
 

Hello Vanmathy

First of all welcome to the Episerver comminuty!

The Alloy demo site solution has a page that allows users to update their profile using a form on page which you could adapt. Code:

Controller: https://github.com/episerver/AlloyDemoKit/blob/master/src/AlloyDemoKit/Controllers/ProfilePageController.cs 

Model: https://github.com/episerver/AlloyDemoKit/blob/master/src/AlloyDemoKit/Models/ViewModels/ProfilePageViewModel.cs 

View: https://github.com/episerver/AlloyDemoKit/blob/master/src/AlloyDemoKit/Views/ProfilePage/Index.cshtml 

David

#197484
Oct 04, 2018 0:00
Vote:
 

Thank you Jorge and David. It helped a lot! :)

#197522
Oct 05, 2018 11:18
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.