Skip to content

Commit

Permalink
Radio button input tag helper disabled atribute
Browse files Browse the repository at this point in the history
  • Loading branch information
yekalkan committed May 23, 2018
1 parent 70fc638 commit e6b83fd
Show file tree
Hide file tree
Showing 8 changed files with 477 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -262,3 +262,4 @@ src/MicroserviceDemo/MicroserviceDemo.TenancyService/Logs/*.txt
src/AbpDesk/Web_PlugIns/AbpDesk.MongoBlog.dll
/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo/Logs/logs.txt
test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo/Logs/logs.txt
test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo/Logs/logs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,12 @@ private AbpTagHelper GetSelectGroupTagHelper(ModelExpression model)

private AbpTagHelper GetAbpRadioInputTagHelper(ModelExpression model)
{
var radioButtonAttribute = GetAttribute<AbpRadioButton>(model.ModelExplorer);
var abpRadioInputTagHelper = _serviceProvider.GetRequiredService<AbpRadioInputTagHelper>();
abpRadioInputTagHelper.AspFor = model;
abpRadioInputTagHelper.AspItems = null;
abpRadioInputTagHelper.Inline = GetAttribute<AbpRadioButton>(model.ModelExplorer).Inline;
abpRadioInputTagHelper.Inline = radioButtonAttribute.Inline;
abpRadioInputTagHelper.Disabled = radioButtonAttribute.Disabled;
abpRadioInputTagHelper.ViewContext = TagHelper.ViewContext;
return abpRadioInputTagHelper;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
[AttributeUsage(AttributeTargets.Property)]
public class AbpRadioButton : Attribute
{
public bool Inline { get; set; } = true;
public bool Inline { get; set; } = false;

public bool Disabled { get; set; } = false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public class AbpRadioInputTagHelper : AbpTagHelper<AbpRadioInputTagHelper, AbpRa

public bool? Inline { get; set; }

public bool? Disabled { get; set; }

public IEnumerable<SelectListItem> AspItems { get; set; }

[HtmlAttributeNotBound]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public override void Process(TagHelperContext context, TagHelperOutput output)
output.TagMode = TagMode.StartTagAndEndTag;
output.Content.SetHtmlContent(html);
}

}

protected virtual string GetHtml(TagHelperContext context, TagHelperOutput output, List<SelectListItem> selectItems)
Expand All @@ -46,9 +45,10 @@ protected virtual string GetHtml(TagHelperContext context, TagHelperOutput outpu
var id = TagHelper.AspFor.Name + "Radio" + selectItem.Value;
var name = TagHelper.AspFor.Name;
var selected = selectItem.Selected ? " checked=\"checked\"" : "";
var disabled = (TagHelper.Disabled??false) ? " disabled" : "";

var htmlPart = "<div class=\"custom-control custom-radio" + inlineClass + "\">\r\n" +
" <input type=\"radio\" id=\"" + id + "\" name=\"" + name + "\" value=\"" + selectItem.Value + "\"" + selected + " class=\"custom-control-input\">\r\n" +
" <input type=\"radio\" id=\"" + id + "\" name=\"" + name + "\" value=\"" + selectItem.Value + "\"" + selected + " class=\"custom-control-input\""+ disabled + ">\r\n" +
" <label class=\"custom-control-label\" for=\"" + id + "\">" + selectItem.Text + "</label>\r\n" +
"</div>";

Expand Down
464 changes: 464 additions & 0 deletions test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo/Logs/logs.txt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<div class="demo-with-code">
<div class="demo-area">
<abp-dynamic-form abp-model="@Model.PersonInput" submit-button="true" />
<abp-dynamic-form abp-model="@Model.PersonInput"/>
<hr />
<h5>Posted Values:</h5>
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class PersonModel
public bool IsActive { get; set; }

[DisplayName("Country")]
[AbpRadioButton(Inline = false)]
[AbpRadioButton(Inline = true)]
[SelectItems(ItemsListPropertyName = nameof(Countries))]
public string Country { get; set; }
}
Expand Down

0 comments on commit e6b83fd

Please sign in to comment.