From 750c21c3ac3022d7aa486779933a3902e7b7e066 Mon Sep 17 00:00:00 2001 From: yekalkan Date: Wed, 23 May 2018 09:47:30 +0300 Subject: [PATCH] Radio button tag helper refactor --- .../Form/AbpDynamicformTagHelperService.cs | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpDynamicformTagHelperService.cs b/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpDynamicformTagHelperService.cs index 2bf7c0517a..2150b00a36 100644 --- a/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpDynamicformTagHelperService.cs +++ b/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpDynamicformTagHelperService.cs @@ -150,23 +150,28 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form protected virtual AbpTagHelper GetSelectGroupTagHelper(TagHelperContext context, TagHelperOutput output, ModelExpression model) { - if (IsRadioGroup(model.ModelExplorer)) - { - var abpRadioInputTagHelper = _serviceProvider.GetRequiredService(); - abpRadioInputTagHelper.AspFor = model; - abpRadioInputTagHelper.AspItems = null; - abpRadioInputTagHelper.Inline = GetAttribute(model.ModelExplorer).Inline; - abpRadioInputTagHelper.ViewContext = TagHelper.ViewContext; - return abpRadioInputTagHelper; - } - else - { - var abpSelectTagHelper = _serviceProvider.GetRequiredService(); - abpSelectTagHelper.AspFor = model; - abpSelectTagHelper.AspItems = null; - abpSelectTagHelper.ViewContext = TagHelper.ViewContext; - return abpSelectTagHelper; - } + return IsRadioGroup(model.ModelExplorer) ? + GetAbpRadioInputTagHelper(model) : + GetSelectGroupTagHelper(model); + } + + private AbpTagHelper GetSelectGroupTagHelper(ModelExpression model) + { + var abpSelectTagHelper = _serviceProvider.GetRequiredService(); + abpSelectTagHelper.AspFor = model; + abpSelectTagHelper.AspItems = null; + abpSelectTagHelper.ViewContext = TagHelper.ViewContext; + return abpSelectTagHelper; + } + + private AbpTagHelper GetAbpRadioInputTagHelper(ModelExpression model) + { + var abpRadioInputTagHelper = _serviceProvider.GetRequiredService(); + abpRadioInputTagHelper.AspFor = model; + abpRadioInputTagHelper.AspItems = null; + abpRadioInputTagHelper.Inline = GetAttribute(model.ModelExplorer).Inline; + abpRadioInputTagHelper.ViewContext = TagHelper.ViewContext; + return abpRadioInputTagHelper; } protected virtual string ProcessSubmitButtonAndGetContent(TagHelperContext context, TagHelperOutput output)