This is a library to make automated forms in Blazor.
AutoForm:
AutoForm.MudComponents:
- Custom form fields
- Automatically generate form fields from a C# class
- Customization options such as priority, allow list, block list.
- AutoForm.MudComponents package already has basic fields created.
- Add support for data validation from attributes
- Make custom field example
- Document AutoForm.AutoFieldBuilders.Create(ExtraLib); and make examples
Add using AutoForm to _Imports.razor
@usingAutoFormJust add this line to your Program.cs
AutoForm.AutoFieldBuilders.Create();Like this:
usingMicrosoft.AspNetCore.Components.Web;usingMicrosoft.AspNetCore.Components.WebAssembly.Hosting;++AutoForm.AutoFieldBuilders.Create();varbuilder=WebAssemblyHostBuilder.CreateDefault(args);
...This will scan your project for classes that implements IBuildableComponent and will register them so they can be used in the AutoFields component to create them.
After registering the custom fields, you can use the AutoFields component inside any blazor component and the fields will be created automagically for you.
Class Model example:
publicclassMyUserModel{[FieldOptions("Nome",0)]publicstringName{get;set;}=null!;[FieldOptions("Login",1)]publicstringLogin{get;set;}=null!;[FieldOptions("Senha",2)]publicstringPassword{get;set;}=null!;[FieldOptions("Email",3)]publicstring?Email{get;set;}[FieldOptions(false)]publicstringWeDontWantThisOne{get;set;}=null!;publicboolAdmin{get;set;}=false;}Blazor Component example:
<EditFormModel="@User"><AutoFieldsModel="@User"/></EditForm>
@code
{
public MyUserModel User = new ();
}And we get a nice form!
- Bootstrap WASM WIP
- Bootstrap Server WIP
- MudBlazor WASM WIP
- MudBlazor Server
This package was inspired by OpenMu's AdminPanel made by sven-n.
