Skip to content

Latest commit

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

AutoForm

This is a library to make automated forms in Blazor.

⚠️Warning: It is under heavy development, and is not yet ready for use.⚠️

Nuget Package

AutoForm:

NuGet stable versionNuGet pre version

AutoForm.MudComponents:

NuGet stable versionNuGet pre version

Features

  • 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.

To-Do

  • Add support for data validation from attributes
  • Make custom field example
  • Document AutoForm.AutoFieldBuilders.Create(ExtraLib); and make examples

Getting Started

Add using AutoForm to _Imports.razor

@usingAutoForm

Just 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!

alt text

Examples

Credits

This package was inspired by OpenMu's AdminPanel made by sven-n.

About

Making creation of forms easier in Blazor

Resources

Stars

7 stars

Watchers

1 watching

Forks

Packages

Used by

Contributors

Languages