Using the input generator

Find the sample usage

An input generator is an object that helps generate inputs of a model. By default, the model is the model of the page, however a different class can be specified. In order to generate the input, it uses a .cshtml file that contains the template. By default the Views/Shared/netcore.simple/_input.cshtml is used as the template. However this template path for a generator can be can be modified.

Following is how you can create a new generator:

var gen1 = Html.GetInputGenerator(); // creates a generator for the current model of the view
var gen2 = Html.GetInputGenerator<Person≥(); // creates a generator for Person

Now, you can use this generator to generate input fields

@gen2.Make(p => p.FirstName)
@gen2.Make(p => p.LastName)

This generates a label, input field and list of error validation messages based on