| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- namespace VberAdmin.Web.Models.Input;
- public class VmInputRadio : VmInputBase
- {
- public VmInputRadio(string name, string displayName) : base(name, displayName, VmInputType.RadioBox)
- {
- DefaultValue = "form-check-input";
- }
- public List<VmInputCheckBoxRadioItem> Items { get; set; }
- /// <summary>
- /// name,value , name,value 成对设置
- /// </summary>
- /// <param name="items"></param>
- /// <returns></returns>
- public VmInputRadio WithItems(params string[] items)
- {
- Items ??= new List<VmInputCheckBoxRadioItem>();
- for (int i = 0; i < items.Length; i++)
- {
- if (items.Length - 2 > 0)
- {
- Items.Add(new VmInputCheckBoxRadioItem(items[i], items[++i]));
- }
- }
- return this;
- }
- public VmInputRadio AddItems(params VmInputCheckBoxRadioItem[] items)
- {
- Items ??= new List<VmInputCheckBoxRadioItem>();
- foreach (var item in items)
- {
- Items.Add(item);
- }
- return this;
- }
- public VmInputRadio AddItems(List<VmInputCheckBoxRadioItem> items)
- {
- Items ??= new List<VmInputCheckBoxRadioItem>();
- Items.AddRange(items);
- return this;
- }
- }
|