mirror of
https://github.com/aljazceru/BTCPayServerPlugins.git
synced 2025-12-17 15:44:26 +01:00
38 lines
978 B
Plaintext
38 lines
978 B
Plaintext
@using System.Linq.Expressions
|
|
@typeparam TValue
|
|
@implements IDisposable
|
|
|
|
@foreach (var message in EditContext.GetValidationMessages(_fieldIdentifier))
|
|
{
|
|
<div @attributes="InputAttributes">
|
|
@message
|
|
</div>
|
|
}
|
|
|
|
@code {
|
|
|
|
[CascadingParameter]
|
|
private EditContext EditContext { get; set; }
|
|
|
|
[Parameter]
|
|
public Expression<Func<TValue>> For { get; set; }
|
|
|
|
[Parameter(CaptureUnmatchedValues = true)]
|
|
public Dictionary<string, object>? InputAttributes { get; set; }
|
|
|
|
private FieldIdentifier _fieldIdentifier;
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
_fieldIdentifier = FieldIdentifier.Create(For);
|
|
EditContext.OnValidationStateChanged += HandleValidationStateChanged;
|
|
}
|
|
|
|
private void HandleValidationStateChanged(object o, ValidationStateChangedEventArgs args) => StateHasChanged();
|
|
|
|
public void Dispose()
|
|
{
|
|
EditContext.OnValidationStateChanged -= HandleValidationStateChanged;
|
|
}
|
|
|
|
} |