I extended the Umbraco model.generated with a custom model and I have an Umbraco form in a partial view returning to my controller with a post. I read a bunch of posts, but I can't figure out why my form returns an empty model to my controller. I set a breakpoint at the beginning of my function in my controller and no matter what I entered in the form, all the fields are null.
Here is my controller :
[HttpGet]
public ActionResult Register(Register model)
{
return PartialView("_Register", model);
}
[HttpPost]
[ActionName("Register")]
public ActionResult RegisterPost(Register model)
{
return PartialView("_Register", model);
}
[HttpPost]
public ActionResult SendRegistration(Register model)
{
Bunch of validation and code of model isValid
What matters is that model.FirstName, model.LastName ... are all null
return CurrentUmbracoPage();
}
Here is my model:
namespace Umbraco.Web.PublishedContentModels{
public partial class Register
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string PhoneNumber { get; set; }
public string EmailAddress { get; set; }
public string ConfirmEmailAddress { get; set; }
public string Password { get; set; }
public string ConfirmPassword { get; set; }
public bool NewsLetterOptIn { get; set; }
public bool AcceptConditions { get; set; }
public string GroupKey { get; set; }
}
Hi Remi,
Is there a reason that you extend umbraco Register model. My advice is to create your own custom model - RegisterModel with the same properties. If you still experiance the issue we can investigate further.
Resolved: Thanks, Mila. I was extending the Umbraco models because otherwise, there is information such as language and other references that were passed without any code from my part using return CurrentUmbracoPage. Since then, I have read another post that said not to extend Umbraco models because it is not something fully functional yet. So I will use my own model and pass the missing element manually.
Model is null on post
I extended the Umbraco model.generated with a custom model and I have an Umbraco form in a partial view returning to my controller with a post. I read a bunch of posts, but I can't figure out why my form returns an empty model to my controller. I set a breakpoint at the beginning of my function in my controller and no matter what I entered in the form, all the fields are null.
Here is my controller :
Bunch of validation and code of model isValid What matters is that model.FirstName, model.LastName ... are all null
Here is my model:
And finally here is my form partial view:
...
... bunch of other fields ...
Sorry for the bunch of code, most of it is repetition or really quick to understand.
Basically, why are the parameters model in SendRegistration(Register model) in my controller empty
Hi Remi, Is there a reason that you extend umbraco Register model. My advice is to create your own custom model - RegisterModel with the same properties. If you still experiance the issue we can investigate further.
Mila
Resolved: Thanks, Mila. I was extending the Umbraco models because otherwise, there is information such as language and other references that were passed without any code from my part using return CurrentUmbracoPage. Since then, I have read another post that said not to extend Umbraco models because it is not something fully functional yet. So I will use my own model and pass the missing element manually.
is working on a reply...