Created
July 13, 2019 09:32
-
-
Save DmitrySikorsky/33e7411bc38194e7ebad987fd37c45ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected TagBuilder CreateInputTag(Localization localization) | |
{ | |
TagBuilder tb = new TagBuilder("input"); | |
tb.TagRenderMode = TagRenderMode.SelfClosing; | |
if (!this.IsValid(localization)) | |
tb.AddCssClass("input-validation-error"); | |
tb.AddCssClass("field__input"); | |
tb.AddCssClass("input"); | |
tb.MergeAttribute("id", this.GetIdentity(localization)); | |
tb.MergeAttribute("name", this.GetIdentity(localization)); | |
string value = this.GetValue(localization); | |
if (!string.IsNullOrEmpty(value)) | |
tb.MergeAttribute("value", value); | |
RequiredAttribute requiredAttribute = this.GetRequiredAttribute(); | |
if (requiredAttribute != null) | |
{ | |
tb.MergeAttribute("data-val", true.ToString().ToLower()); | |
tb.MergeAttribute("data-val-required", string.Empty); | |
} | |
return tb; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment