@using BTCPayServer.Forms @using Newtonsoft.Json.Linq @model BTCPayServer.Abstractions.Form.Field @{ var selectField = (SelectField) (Model is not SelectField ? JObject.FromObject(Model).ToObject() : Model); selectField.Options ??= new List(); selectField.Options.ForEach(item => { item.Selected = item.Value == Model.Value; }); var isInvalid = ViewContext.ModelState[Model.Name]?.ValidationState is Microsoft.AspNetCore.Mvc.ModelBinding.ModelValidationState.Invalid; var errors = isInvalid ? ViewContext.ModelState[Model.Name].Errors : null; }
@(isInvalid && errors.Any() ? errors.First().ErrorMessage : string.Empty) @if (!string.IsNullOrEmpty(selectField.HelpText)) {
@Safe.Raw(selectField.HelpText)
}