btcpayserver/BTCPayServer/Forms/HtmlSelectFormProvider.cs
2023-04-10 11:07:03 +09:00

31 lines
802 B
C#

using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using BTCPayServer.Abstractions.Form;
using Microsoft.AspNetCore.Mvc.Rendering;
namespace BTCPayServer.Forms;
public class HtmlSelectFormProvider : FormComponentProviderBase
{
public override void Register(Dictionary<string, IFormComponentProvider> typeToComponentProvider)
{
foreach (var t in new[] {
"select"})
typeToComponentProvider.Add(t, this);
}
public override string View => "Forms/SelectElement";
public override void Validate(Form form, Field field)
{
if (field.Required)
{
ValidateField<RequiredAttribute>(field);
}
}
}
public class SelectField : Field
{
public List<SelectListItem> Options { get; set; }
}