get model data from form during post in Umbraco 10

48 Views Asked by At

I have some major problem getting the data from a form that is being submitted in Umbraco 10. My form look like this..

<form id="changeInfo" method="post" asp-controller="ChangeInfoController" asp- 
action="Save">

And my controller..

[HttpPost]
public IActionResult ChangeInfoController(ContentModel model)
{
//model.Form is null

In my generated file from Umbraco the properties that the user should enter is of type FormInput, when I post the form my form is always null, what am I doing wrong here?

1

There are 1 best solutions below

0
Jannik Anker On

Have you looked at the docs here? https://docs.umbraco.com/umbraco-cms/fundamentals/code/creating-forms - note that there may be changes between Umbraco versions, so make sure to select the one you're using.

You haven't really included enough code for me to see if your approach is in line with the docs, but your code does looks a little "off" to me. Are you posting to the main controller method? That's probably not right - and you should probably have a custom model that matches your form fields, instead of relying on a ContentModel which I'm assuming is something Umbraco generated for you?