This guide explains how to integrate the Blazor FormBuilder with your existing Blazor application. The integration process involves the following steps:
Add the FormBuilder
Razor class library to your Blazor application as a project reference.
Add AddFormBuilder()
to the service collection in the Program.cs
file.
You also need to pass the FormApiHost
to the AddFormBuilder()
method.
The FormApiHost
is the base URL of the Form Builder API.
Example:
builder.Services.AddFormBuilder(options =>
{
options.FormApiHost = "https://localhost:8000";
});
You can also set optional parameters such as Theme
and CacheExpiration
:
Theme
: The theme to use for the Radzen components. The default value ismaterial
. You can view the Themes class for available themes.CacheExpiration
: The expiration time for the form cache. The default value is30 minutes
. By default, the LOV (list of values) API requests are cached.
Example:
builder.Services.AddFormBuilder(options =>
{
options.FormApiHost = "https://localhost:8000";
options.Theme = Themes.Standard;
options.CacheExpiration = TimeSpan.FromMinutes(15);
});
Add the <InitFormBuilder />
component to the layout file to initialize the Radzen components and load static files.
For example, add the following code to the MainLayout.razor
file:
<InitFormBuilder />
And don't forget to include namespace in the _Imports.razor
file:
@using FormBuilder
@using FormBuilder.Components
That's it! You have successfully integrated the Blazor FormBuilder with your Blazor application.
The FormEditor
component is used to design forms.
To use the FormEditor
component, add the following code to the desired page:
<FormEditor />
To read more about the FormEditor
component, refer to the Form Editor Component Reference.
The FormRenderer
component is used to render forms.
To use the FormRenderer
component, add the following code to the desired page:
<FormRenderer FormId="1" />
To read more about the FormRenderer
component, refer to the Form Renderer Component Reference.
You can view a sample Blazor application that integrates the Blazor Form Builder components in the src/FormBuilder.DesignerApp
project.
The sample application demonstrates how to design and render forms using the Blazor FormBuilder components.