I've been adding xVal to the NerdDinner app - so far so good, I get client-side validation with jQuery.validate in one line, which is truly beautiful. But I can't seem to get xVal to validate a complex object. Say I have a Dinner object that looks like this:
public class Dinner
{
[Required]
public string Title { get; set; }
}
and another object, a container:
public class DinnerWrapper
{
public Dinner Dinner { get; set; }
public string Name { get; set; }
}
If my controller passes Dinner
to the View, I can get xVal to perform client-side validation at the end of my form, like this:
<% using (Html.BeginForm())
{ %>
<fieldset>
<p>
<label for="Title">
Dinner Title:</label>
<%= Html.TextBox("Title") %>
<%= Html.ValidationMessage("Title", "*") %>
</p>
</fieldset>
<% } %>
<%=Html.ClientSideValidation<Dinner>()%>
But I can't get it to work when I am passing DinnerWrapper - xVal doesn't perform client-side validation with the following setup:
<% using (Html.BeginForm())
{ %>
<fieldset>
<p>
<label for="Title">
Dinner Title:</label>
<%= Html.TextBox("Title", Model.Dinner.Title) %>
<%= Html.ValidationMessage("Title", "*") %>
</p>
</fieldset>
<% } %>
<%=Html.ClientSideValidation<DinnerWrapper>()%>
Any ideas? So far I've successfully integrated xVal (and NHaml) into the NerdDinner app, but I seem to have hit a roadblock.