I have a Razor file called Reservation.cshtml. Which is a Macro Partial View.
I would like to have a form inside it. At the start I have
@inherits Umbraco.Web.Macros.PartialViewMacroPage
I tried to add the model as well but then I always get an error message
The 'inherits' keyword is not allowed when a 'model' keyword is used.
I’m a getting a complete headache why this is so frustrating and complicated.
This is what I have so far:
@{
var reservation = new NgakNgakBeach.Models.Reservation();
}
@using (Html.BeginUmbracoForm("MakeReservation", "Reservation",
{ enctype = "multipart/form-data" }, htmlAttributes, FormMethod.Post))
{
@Html.EditorFor(x => reservation.RoomName)
<input type="submit" />
}
and my Surface Controller:
[HttpPost]
public ActionResult MakeReservation(Reservation model)
{
return CurrentUmbracoPage();
}
When I debug this the MakeReservation Action gets called perfectly well but the model is always empty.. Why? What is the correct way of having a form inside a PartialViewMacro with custom markup?
I think I need to set the Model somehow, but as mentioned before I also need the @inherits Umbraco.Web.Macros.PartialViewMacroPage
I hope you guys can help me out!
Thanks
This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/61624-place-a-form-inside-a-partialviewmacropage