diff --git a/src/FormBuilder/Components/FieldValidatorsEditor.razor b/src/FormBuilder/Components/FieldValidatorsEditor.razor
index 60c9b40..6446de4 100644
--- a/src/FormBuilder/Components/FieldValidatorsEditor.razor
+++ b/src/FormBuilder/Components/FieldValidatorsEditor.razor
@@ -37,22 +37,58 @@
{
case RequiredValidator requiredValidator:
-
+
+
+
break;
case EmailValidator emailValidator:
-
+
+
+
break;
case LengthValidator lengthValidator:
-
+
+
+
break;
case NumericRangeValidator numericRangeValidator:
-
+
+
+
break;
}
diff --git a/src/FormBuilder/Components/FieldValidatorsEditor.razor.cs b/src/FormBuilder/Components/FieldValidatorsEditor.razor.cs
index d13610c..3983671 100644
--- a/src/FormBuilder/Components/FieldValidatorsEditor.razor.cs
+++ b/src/FormBuilder/Components/FieldValidatorsEditor.razor.cs
@@ -15,7 +15,22 @@ public partial class FieldValidatorsEditor : ComponentBase
private void AddValidator(ValidatorType validatorType)
{
+ if (HasValidator(validatorType))
+ {
+ return;
+ }
+
var validator = ValidatorFactory.Create(validatorType);
Field.Validators.Add(validator);
}
+
+ private void RemoveValidator(Validator validator)
+ {
+ Field.Validators.Remove(validator);
+ }
+
+ private bool HasValidator(ValidatorType validatorType)
+ {
+ return Field.Validators.Any(v => v.Type == validatorType);
+ }
}
diff --git a/src/FormBuilder/Components/FormField.razor b/src/FormBuilder/Components/FormField.razor
index 604e807..d363934 100644
--- a/src/FormBuilder/Components/FormField.razor
+++ b/src/FormBuilder/Components/FormField.razor
@@ -15,13 +15,25 @@
break;
case SelectField selectField:
-
-
+ if (Disabled)
+ {
+
+
+ }
+ else
+ {
+
+
+ }
+
break;
case NumericField numericIntField:
+ @Header
diff --git a/src/FormBuilder/Components/ValidatorPropertyEditor.razor.cs b/src/FormBuilder/Components/ValidatorPropertyEditor.razor.cs
index 5d89800..57ea3ad 100644
--- a/src/FormBuilder/Components/ValidatorPropertyEditor.razor.cs
+++ b/src/FormBuilder/Components/ValidatorPropertyEditor.razor.cs
@@ -9,6 +9,9 @@ public partial class ValidatorPropertyEditor : ComponentBase where TValu
[Parameter, EditorRequired]
public TValue Validator { get; set; } = default!;
+
+ [Parameter]
+ public RenderFragment? Header { get; set; }
#endregion
}
diff --git a/src/FormBuilder/Models/Fields/Field.cs b/src/FormBuilder/Models/Fields/Field.cs
index 68198e9..75103a0 100644
--- a/src/FormBuilder/Models/Fields/Field.cs
+++ b/src/FormBuilder/Models/Fields/Field.cs
@@ -104,6 +104,8 @@ private void HandleValidatorsCollectionChanged(object? sender, NotifyCollectionC
{
validator.PropertyChanged += RaiseValidatorsChanged;
}
+
+ OnPropertyChanged(nameof(Validators)); // Notify that the collection has changed
}
else if (args is { Action: NotifyCollectionChangedAction.Remove, OldItems: not null })
{
@@ -111,6 +113,8 @@ private void HandleValidatorsCollectionChanged(object? sender, NotifyCollectionC
{
validator.PropertyChanged -= RaiseValidatorsChanged;
}
+
+ OnPropertyChanged(nameof(Validators));
}
}