#How to differentiate form posts from two different mvc forms placed in a single page

1 messages · Page 1 of 1 (latest)

mighty nebula
#

I have two mvc forms (contact form and call form) in an Umbraaco 13 web site. When used in seperate pages they work well. But if i place them in a single page and submit one form the other form also returns the values if form fails validation (e.g. an unchecked consent checkbox). When the form is submitted successfully both forms return their confirmation message.

Any advices?

Thanks in advance.

crisp sleet
#

That sounds strange and should not happen by default. Do you have a form tag surrounding those forms?

mighty nebula
#

Yes there's form tag. I'm sharing the html code generated and also model, view, controller screen shots. Do i miss something?

crisp sleet
#

But is there a form tag surrounding those forms? As in; do you have forms within eachother? How is the submit going? Is it just a post, or are you doing it client side with javascript?

mighty nebula
#

No the forms have seperate form tags.
Using
@using (Html.BeginUmbracoForm<ContactFormController>(nameof(ContactFormController.Submit)))
{
....
}
adds <form>......</form>
I don't think i make a clientside post.

crisp sleet
#

Just checked your views, I assume that in both views your checking for TempData["success"]? If so, than that's your issue.

#

As both views than check the same value in the tempdata, they both do stuff depending on that.

#

You could just use a different key for each form in your TempData, so it's unique for that form

#

For ex, TempData["Form1_Succes"]

mighty nebula
#

Let me try.

mighty nebula
#

I tried to use unique variable names as email1, email2. Didn't help either.

#

Even tried the combine the controllers as attached. It didn't also help 😦

crisp sleet
#

What isn't working?