Hi - im trying something that might not be the best approach so feel free to correct me :-)
I basically have a website built in Bootstrap with a form i want submitted and validated with ModelState.IsValid and displayed with the standard Bootstrap display.
Its just an email address i want to submit to a controller that will validate it with:
[HttpPost]
public async Task<IActionResult> CreateClaimRequest(ClaimRequest request)
{
if (ModelState.IsValid)
{
//Do something here, send an email or something
}
return CurrentUmbracoPage();
}
The ClaimRequest class would just be a simple class i create so i can add [Required] annotations to it and that would make the ModelState.IsValid to set failed modelState when the email is not filled out.
This usually works just fine and let me do nice validations, but im getting an error with this setup because i tried do better organize my umbraco content nodes, so i have one main content node with settings for the website and a descendant node to hold my parameters - im using it in the view like this:
Submit forms with complex models
Hi - im trying something that might not be the best approach so feel free to correct me :-)
I basically have a website built in Bootstrap with a form i want submitted and validated with ModelState.IsValid and displayed with the standard Bootstrap display.
So i have this view:
Its just an email address i want to submit to a controller that will validate it with:
The ClaimRequest class would just be a simple class i create so i can add [Required] annotations to it and that would make the ModelState.IsValid to set failed modelState when the email is not filled out.
This usually works just fine and let me do nice validations, but im getting an error with this setup because i tried do better organize my umbraco content nodes, so i have one main content node with settings for the website and a descendant node to hold my parameters - im using it in the view like this:
but then i create the input parameter in the form with:
The resulting input name is "pacModel.EmailAddress" and i cant add a parameter with a dot in my request class.
Am i just doing this the wrong way?
Hi Jacob,
Does it work when you add a bind prefix to the controller action? Like:
If your model contains arrays or other complex stuf, the default TypeFormatter could be an problem.
Best regards,
iNETZO
Hi That worked, thank you for providing the solution
is working on a reply...