Created
July 25, 2014 13:26
-
-
Save jbogard/8b53aff35ddf043b5b5f 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
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