Home - ProCodersPtyLtd/MasterDetailsDataEntry GitHub Wiki

Platz.SqlForms - Blazor Dynamic Forms framework

Platz.SqlForms lets you build interactive web UIs using C# and Blazor. Platz.SqlForms applications are composed of reusable Dynamic Form definitions made in C#, Blazor UI pages and Entity Framework context.

Platz.SqlForms is oriented on entry- and middle- level developers. It is very useful for a rapid creation of the UI for the given or being constructed SQL database, and it initially doesn't require any knowledge in Web technologies, like HTML, CSS, and JavaScript.

Platz.SqlForms - Application

To build Platz.SqlForms application it is required to create a Visual Studio project using "Blazor App" template. Currently only "Blazor Server App" is supported. Blazor is built on .NET Core 3.1 and this is the main framework for Platz.SqlForms too.

The next step is to add Entity Framework Core database Model (entities and database context). It can be code first Model or a created Model from an existing database.

Having Blazor application and database Model entities you define Dynamic Forms in C# class and show them on Blazor pages using Platz.SqlForms razor components.

To define a Dynamic Form the fluent notation is used - it is the same approach as in Entity Framework Core. This example shows typical Dynamic Form definition:

using Platz.SqlForms;
using MasterDetailsDataEntry.Demo.Database.School;

namespace MasterDetailsDataEntry.Demo.MyForms
{
    public class DepartmentForm : DetailsForm<SchoolContext>
    {
        protected override void Define(FormBuilder builder)
        {
            builder.Entity<Department>(e =>
            {
                e.Property(p => p.DepartmentId).IsFilter().IsUnique();

                e.Property(p => p.Name).IsRequired();

                e.Property(p => p.StartDate).IsRequired();

                e.Property(p => p.Budget).IsRequired();

                e.Property(p => p.Administrator).Dropdown<Person>().Set(c => c.PersonId, c => c.FullName).IsRequired();

                e.Button("Details", "Details...");
            });
        }
    }
}

In this code DepartmentForm is based on abstract class DetailsForm and uses SchoolContext template parameter pointing to Entity Framework DB Context. DepartmentForm implements abstract method Define(FormBuilder builder) providing Department entity template parameter. Then each property of Department entity can be defined by definition attributes: IsRequired, IsFilter, IsUnique, etc. Parsing fluent flow notation Platz.SqlForms framework understands how it should render Dynamic Form.

To show the defined Dynamic Form FormDetailsComponent razor component should be placed on a Blazor page:

@page "/DepartmentDetails"
@using MasterDetailsDataEntry.Demo.MyForms

<FormDetailsComponent FormType="@typeof(DepartmentForm)" FilterValue="null" ItemButtonClicked="@ButtonClicked" />

@code {
    private async Task ButtonClicked(ItemButtonClickedArgs args)
    {
    }
}

When page is opened Platz.SqlForms framework will read data from SQL database and render it as a table:

DepartmentDetails view

Users will be able to edit, add or delete records using Action buttons. The custom buttons (Details on the picture) are also supported.

⚠️ **GitHub.com Fallback** ⚠️