Skip to content

Commit c78b475

Browse files
committed
Conditionally register default field renderers
1 parent 353bddc commit c78b475

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

FormCraft/Forms/Extensions/ServiceCollectionExtensions.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,16 @@ public static IServiceCollection AddFormCraft(this IServiceCollection services)
3636

3737
// Only register built-in field renderers if no UI framework adapter is registered
3838
// This allows UI framework-specific renderers to take precedence
39-
services.AddScoped<IFieldRenderer, StringFieldRenderer>();
40-
services.AddScoped<IFieldRenderer, IntFieldRenderer>();
41-
services.AddScoped<IFieldRenderer, DecimalFieldRenderer>();
42-
services.AddScoped<IFieldRenderer, DoubleFieldRenderer>();
43-
services.AddScoped<IFieldRenderer, BoolFieldRenderer>();
44-
services.AddScoped<IFieldRenderer, DateTimeFieldRenderer>();
45-
services.AddScoped<IFieldRenderer, FileUploadFieldRenderer>();
39+
if (!services.Any(s => s.ServiceType == typeof(IUIFrameworkAdapter)))
40+
{
41+
services.AddScoped<IFieldRenderer, StringFieldRenderer>();
42+
services.AddScoped<IFieldRenderer, IntFieldRenderer>();
43+
services.AddScoped<IFieldRenderer, DecimalFieldRenderer>();
44+
services.AddScoped<IFieldRenderer, DoubleFieldRenderer>();
45+
services.AddScoped<IFieldRenderer, BoolFieldRenderer>();
46+
services.AddScoped<IFieldRenderer, DateTimeFieldRenderer>();
47+
services.AddScoped<IFieldRenderer, FileUploadFieldRenderer>();
48+
}
4649

4750
// Register security services
4851
services.AddScoped<IEncryptionService, BlazorEncryptionService>();

0 commit comments

Comments
 (0)