Skip to content

From a C# type

One line generates a complete form from any POCO. Labels, field types, options and validation come from the type and its DataAnnotations — and fields inherited from a base class come first, in the order the class reads.

Live form

View source
@page "/quickstart"

@* ConfigureState settles the state the view builds for you, so wanting one setting does not mean
   constructing, holding and disposing a BormState by hand. *@
<BormView Definition="_schema" Model="_model"
          ConfigureState="s => s.ValidationTrigger = BormValidationTrigger.OnBlur"
          OnValidSubmit="HandleSubmit" SubmitText="Create account" />

@code {
    private readonly AccountSignup _model = new();
    private BormDefinition _schema = default!;

    protected override void OnInitialized()
    {
        // Zero-config: generate the whole form from the type.
        _schema = BormSchemaGenerator.Generate<AccountSignup>();
    }

    private void HandleSubmit(BormState state)
    {
        var json = System.Text.Json.JsonSerializer.Serialize(_model,
            new System.Text.Json.JsonSerializerOptions { WriteIndented = true });
    }
}
An unhandled error has occurred. Reload 🗙