A library with some Form Extensions for Blazor:
- LabelText
You can install from Nuget using the following command:
Install-Package Blazored.FormExtensions
Or via the Visual Studio NuGet package manager.
Start by add the following using statement to your root _Imports.razor
.
@using Blazored.FormExtensions
You can use this within a EditForm
component:
<EditForm Model="@Model">
<p>
<LabelText For="@(() => Model.First)" />
<InputText @bind-Value="@Model.First" />
</p>
<p>
<LabelText For="@(() => Model.Last)" />
<InputText @bind-Value="@Model.Last" />
</p>
<p>
<LabelText For="@(() => Model.EmailAddress)" />
<InputText @bind-Value="@Model.EmailAddress" />
</p>
</EditForm>
@code {
Person Model { get; set; } = new Person();
}
Make sure to setup and configure the IStringLocalizer
correctly in the Startup.cs
like:
public void ConfigureServices(IServiceCollection services)
{
+ services.AddRazorPages().AddViewLocalization(options => options.ResourcesPath = "Resources");
+ services.AddLocalization(options => options.ResourcesPath = "Resources");
+ services.AddSingleton(typeof(IStringLocalizer), typeof(StringLocalizer<SharedLocalization.SharedResources>));
}
Make sure to setup and configure the IStringLocalizer
correctly in the Program.cs
like:
public void ConfigureServices(IServiceCollection services)
{
+ builder.Services.AddLocalization(options => options.ResourcesPath = "Resources");
+ builder.Services.AddSingleton(typeof(IStringLocalizer), typeof(StringLocalizer<SharedLocalization.SharedResources>));
}