I have a contact form on my website that, when filled out properly, creates a node in my Content section. In 7.0.2 there are no issues in the process of filling out the form. In 7.0.3 there are no error messages when a form is submitted with required fields left blank, and there's no success message when a form is submitted with all fields filled out correctly.
This is my controller:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
using System.Web.Security;
using umbraco.cms.businesslogic.member;
using System.ComponentModel.DataAnnotations;
using Umbraco.Web.Models;
public class ContactSurfaceController : Umbraco.Web.Mvc.SurfaceController
{
[HttpPost]
public ActionResult ContactForm(ContactModel contact)
{
//model not valid, do not save, but return current umbraco page
if (!ModelState.IsValid)
{
//Perhaps you might want to add a custom message to the ViewBag
//which will be available on the View when it renders (since we're not
//redirecting)
return CurrentUmbracoPage();
}
contact.UmbracoServiceContext = this.Services;
contact.Save();
//Add a message in TempData which will be available
//in the View after the redirect
ViewBag.Message = "Your RSVP was successfully sent! Thank you!";
//redirect to current page to clear the form
return CurrentUmbracoPage();
}
}
and this is the partial view:
@model ContactModel
@if(ViewBag.Message != null)
{
<label>@ViewBag.Message</label>
}
else
{
using (Html.BeginUmbracoForm<ContactSurfaceController>("ContactForm"))
{
<fieldset>
<legend></legend>
<div id="contact-form">
<label>
@Html.TextBoxFor(model => model.Name, new { placeholder = "Name" })
@Html.ValidationMessageFor(model => model.Name)
</label>
<label>
@Html.DropDownListFor(
model => model.Dropdown,
new SelectList(
new List<Object> {
new { value = 0 , text = "+1 Guest" },
new { value = 1 , text = "YES" },
new { value = 2 , text = "NO" },
},
"value",
"text",
Model.Dropdown
)
)
</label>
<label>
@Html.TextBoxFor(model => model.Email, new { placeholder = "Email*" })
**I know that the model is being validated, and there are validation messages in the model state. The validation messages are on the object, but not showing up on the page.
Contact form working on 7.0.2, not on 7.0.3
I have a contact form on my website that, when filled out properly, creates a node in my Content section. In 7.0.2 there are no issues in the process of filling out the form. In 7.0.3 there are no error messages when a form is submitted with required fields left blank, and there's no success message when a form is submitted with all fields filled out correctly.
This is my controller:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
using System.Web.Security;
using umbraco.cms.businesslogic.member;
using System.ComponentModel.DataAnnotations;
using Umbraco.Web.Models;
public class ContactSurfaceController : Umbraco.Web.Mvc.SurfaceController
{
[HttpPost]
public ActionResult ContactForm(ContactModel contact)
{
//model not valid, do not save, but return current umbraco page
if (!ModelState.IsValid)
{
//Perhaps you might want to add a custom message to the ViewBag
//which will be available on the View when it renders (since we're not
//redirecting)
return CurrentUmbracoPage();
}
contact.UmbracoServiceContext = this.Services;
contact.Save();
//Add a message in TempData which will be available
//in the View after the redirect
ViewBag.Message = "Your RSVP was successfully sent! Thank you!";
//redirect to current page to clear the form
return CurrentUmbracoPage();
}
}
and this is the partial view:
@model ContactModel
@if(ViewBag.Message != null)
{
<label>@ViewBag.Message</label>
}
else
{
using (Html.BeginUmbracoForm<ContactSurfaceController>("ContactForm"))
{
<fieldset>
<legend></legend>
<div id="contact-form">
<label>
@Html.TextBoxFor(model => model.Name, new { placeholder = "Name" })
@Html.ValidationMessageFor(model => model.Name)
</label>
<label>
@Html.DropDownListFor(
model => model.Dropdown,
new SelectList(
new List<Object> {
new { value = 0 , text = "+1 Guest" },
new { value = 1 , text = "YES" },
new { value = 2 , text = "NO" },
},
"value",
"text",
Model.Dropdown
)
)
</label>
<label>
@Html.TextBoxFor(model => model.Email, new { placeholder = "Email*" })
@Html.ValidationMessageFor(model => model.Email)
</label>
<label>
@Html.TextBoxFor(model => model.Phone, new { placeholder = "Mobile Phone Number" })
</label>
<label>
@Html.TextBoxFor(model => model.Diet, new { placeholder = "Dietary restrictions" })
</label>
<label>
@Html.TextAreaFor(model => model.Comment, new { placeholder = "Message*", @rows="9" })
@Html.ValidationMessageFor(model => model.Comment)
</label>
<label>
<div style="text-align: left;" class="form-buttons-wrapper">
<input type="submit" value="Send" />
</div>
</label>
</div>
</fieldset>
}
}
**I know that the model is being validated, and there are validation messages in the model state. The validation messages are on the object, but not showing up on the page.
Having same problem in umbrac 7
is working on a reply...