-
-
Save hoangitk/77b2b07228c38d6d406a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
public static HtmlTag FormBlock<T>(this HtmlHelper<T> helper, | |
Expression<Func<T, object>> expression, | |
Action<HtmlTag> labelModifier = null, | |
Action<HtmlTag> inputBlockModifier = null, | |
Action<HtmlTag> inputModifier = null, | |
Action<HtmlTag> validatorModifier = null | |
) where T : class | |
{ | |
labelModifier = labelModifier ?? (_ => { }); | |
inputBlockModifier = inputBlockModifier ?? (_ => { }); | |
var divTag = new HtmlTag("div"); | |
divTag.AddClass("form-group"); | |
var labelTag = helper.Label(expression); | |
labelModifier(labelTag); | |
var inputBlockTag = helper.InputBlock( | |
expression, | |
inputModifier, | |
validatorModifier); | |
inputBlockModifier(inputBlockTag); | |
divTag.Append(labelTag); | |
divTag.Append(inputBlockTag); | |
return divTag; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment