<%=form.Input(p => p.Name).Label("Name") %>
<%=form.Input(p => p.BirthDate).Label("Birth date") %>
<% }); %>
This is all there is to creating an MVC XForm. Note that I'm creating a XForm based on my model, and that I want an input field for the Name and BirthDate properties, each with a label supplied.
On to rendering: the HTML generated by MVC XForm looks like the following:
<form action="" method="post" class="xf xform">
<div class="xf input text">
<input id="Name" type="text" name="Name" value="Maarten Balliauw"/>
<div class="xf input date">
<label for="BirthDate">Birth date</label>
<input id="BirthDate" type="text" name="BirthDate" value="21-12-1983"/>
That's actually nice, clean HTML markup! Note the CSS classes that are applied on certain fields. For example, the div element for BirthDate has a CSS class "date", which can be used by, for example, jQuery to enable a date picker on that field.
In the CodePlex download (http://www.codeplex.com/mvcxforms), there is a sample project which makes use of all simple and advanced ideas in MVC XForms. You can also check out Jon Curtis' blog posts on MVC XForms to read some more samples.
This is an imported post. It was imported from my old blog using an automated tool and may contain formatting errors and/or broken images.