Because you shouldn't have to update your html when you update your object model
Specify custom templates for rendering different object types.
Styled for bootstrap (by default)
FormFactory.Standalone can be used in non ASP projects like console apps, services or WebAPI projects.
FormFactory renders complex object forms automatically. It refects over an object model or method signature, and builds an intermediate model representing the form and properties. These models are then rendered using customisable templates.
FormFactory can build complex nested forms with rich content pickers. By following a few simple code conventions, properties with multiple choices and suggested values can be written in a few lines of code.
//In a cshtml file @FF.PropertiesFor(someObject).Render(Html);
For ASP.NET MVC 5 install-package FormFactory install-package FormFactory.AspMvc install-package EmbeddedResourceVirtualPathProvider * For ASP.NET MVC Core install-package FormFactory install-package FormFactory.AspNetCore Then configure core to serve embedded files ( see startup.cs lines 36 and 60)* You can install FormFactory.Templates if you don't want to use the EmbeddedResourceVirtualPathProvider
<link href="/Content/FormFactory/FormFactory.css" rel="stylesheet" type="text/css"/> <script src="/Scripts/FormFactory/FormFactory.js" type="text/javascript"></script>
In AutoCompleteExample.cs
Could not get source from https://raw.github.com/mcintyre321/FormFactory/master/FormFactory.AspMvc.Example/Models/Examples/AutoCompleteExample.cs
In ChoicesExample.cs
Could not get source from https://raw.github.com/mcintyre321/FormFactory/master/FormFactory.AspMvc.Example/Models/Examples/ChoicesExample.cs
In DateTimePickersExample.cs
Could not get source from https://raw.github.com/mcintyre321/FormFactory/master/FormFactory.AspMvc.Example/Models/Examples/DateTimePickersExample.cs
In DynamicallyHiddenPropertiesExample.cs
Could not get source from https://raw.github.com/mcintyre321/FormFactory/master/FormFactory.AspMvc.Example/Models/Examples/DynamicallyHiddenPropertiesExample.cs
In EditableCollectionsExample.cs
Could not get source from https://raw.github.com/mcintyre321/FormFactory/master/FormFactory.AspMvc.Example/Models/Examples/EditableCollectionsExample.cs
In EnumExample.cs
Could not get source from https://raw.github.com/mcintyre321/FormFactory/master/FormFactory.AspMvc.Example/Models/Examples/EnumExample.cs
In InhertitanceExample.cs
Could not get source from https://raw.github.com/mcintyre321/FormFactory/master/FormFactory.AspMvc.Example/Models/Examples/InhertitanceExample.cs
In ListRenderingExample.cs
Could not get source from https://raw.github.com/mcintyre321/FormFactory/master/FormFactory.AspMvc.Example/Models/Examples/ListRenderingExample.cs
In NestedFormsExample.cs
Could not get source from https://raw.github.com/mcintyre321/FormFactory/master/FormFactory.AspMvc.Example/Models/Examples/NestedFormsExample.cs
In NestedFormsExample2.cs
Could not get source from https://raw.github.com/mcintyre321/FormFactory/master/FormFactory.AspMvc.Example/Models/Examples/NestedFormsExample2.cs
In SimplePropertiesExample.cs
Could not get source from https://raw.github.com/mcintyre321/FormFactory/master/FormFactory.AspMvc.Example/Models/Examples/SimplePropertiesExample.cs
Given this action...
[HttpPost] public virtual ActionResult SignIn(string email, [Password] string password) { //... }
..writing this in the view...
var form = Html.FormForAction((HomeController c, string p0, string p1) => c.SignIn(p0, p1)); @form.Render(Html); //renders the form
...will render this form:
By default FF reflects against a view model to produce a `PropertyVm[]` array, but you can also create the properties programatically, e.g. you could load a form definition from a database
You can build any of the examples above.
//Build a model up in your controller or view var formModel = new[] { new PropertyVm(typeof(DateTime) , "date") { DisplayName = "Your birthday", NotOptional =true, GetCustomAttributes = () => new object[] { new DateAttribute() } }, new PropertyVm(typeof(string) , "textmessage") { DisplayName = "Type a message:", NotOptional =false, GetCustomAttributes = () => new object[] { new MultilineTextAttribute(), new DisplayAttribute(){Prompt = "placeholder??"}, new DisplayAttribute(Description = "Type anything here.") }, }, new PropertyVm(typeof(string) , "number") { DisplayName = "Select a number", NotOptional =false, Choices = new List() {"one","two","three","four" }, }, new PropertyVm(typeof(string), "username") { DisplayName = "Username", NotOptional = true, Suggestions = new List () { "holy poo" }, }, new PropertyVm(typeof(string), "password") { DisplayName = "Password", NotOptional = true, GetCustomAttributes = () => new object[]{ new PasswordAttribute() } }, new PropertyVm(typeof(string), "os") { DisplayName = "Operating System", NotOptional = true, Choices = new List () {"OSX", "IOS", "Windows", "Android"}, Value = "Windows", //Preselect windows GetCustomAttributes = () => new object[] {new RadioAttribute(), new System.ComponentModel.DescriptionAttribute("Make a choice above.") } }, new PropertyVm(typeof(bool), "check") { DisplayName = "Check if happy", NotOptional = true, Value = false, //Preselect false (unchecked) GetCustomAttributes = () => new object[] {new FormFactory.Attributes.LabelOnRightAttribute() } // right label }, new PropertyVm(typeof(bool), "check2") { DisplayName = "Check if sad", Value = false, //Preselect false (unchecked) NotOptional =true } }; ... //render it in your view @formModel.Render(Html)
...will render this form: