I'm creating a form that allows front end users to select a number of items from an umbraco repository. As the items in this repository can change I can't hard code all the items into the model, so I'm outputting input boxes in the view and picking them up again in the controller.
I'm calling @Html.Action("RenderCreate", "CreateSurface") in a Macro Partial and populating the model with the repository content in this method.
The problem comes when validation for the form fails. The method processes the form and if the validation fails calls CurrentUmbracoPage() as per the following documentation:
The model is correct at this point, with the repository items and select items stored in arrays. However as the link above states the model doesn't persist, so I lose all the data I have just stored in the array and RenderCreate is recalled.
I don't know if I'm going about this in fundamentally the wrong way or if there is a way to redirect to the page and pass the model I've created to the view?
MVC Form validation
Hi all,
I'm creating a form that allows front end users to select a number of items from an umbraco repository. As the items in this repository can change I can't hard code all the items into the model, so I'm outputting input boxes in the view and picking them up again in the controller.
I'm calling @Html.Action("RenderCreate", "CreateSurface") in a Macro Partial and populating the model with the repository content in this method.
The problem comes when validation for the form fails. The method processes the form and if the validation fails calls CurrentUmbracoPage() as per the following documentation:
http://our.umbraco.org/documentation/Reference/Mvc/forms
The model is correct at this point, with the repository items and select items stored in arrays. However as the link above states the model doesn't persist, so I lose all the data I have just stored in the array and RenderCreate is recalled.
I don't know if I'm going about this in fundamentally the wrong way or if there is a way to redirect to the page and pass the model I've created to the view?
is working on a reply...