MRCollective / ChameleonForms

Shape-shifting your forms experience in ASP.NET Core MVC
MIT License
254 stars 56 forks source link

Create inline helper overloads for IFieldConfiguration methods that take a IHtmlString #136

Closed fsateler closed 7 years ago

fsateler commented 9 years ago

For example, for Append, OverrideFieldHtml, InlineLabel and others it can be very useful to use the following:

s.FieldFor(p => p.Prop).OverrideFieldHtml(@<span>Inline html <u>here</u>!</span>)

The implementation is simple:

public IFieldConfiguration OverrideFieldHtml(this IFieldConfiguration src, Func<object,IHtmlString> genHtml) {
    return src.OverrideFieldHtml(genHtml(null));
}
robdmoore commented 9 years ago

Cool idea! More than happy to accept pull requests for this.