title: Creating A Helper To Override CheckboxFor
body: <p>I am using bootstrap 5 in a new project I am starting, and rather than having to write all the scaffolding around a form field, I have decided to create a wrapper to do this for me automatically.</p>
  
  <p>I have used the following syntax for textboxfor, textareafor and dropdownlist:</p>
  
  <pre><code>public static MvcHtmlString MyTextBoxFor&lt;TModel, TProperty&gt;(
          this HtmlHelper&lt;TModel&gt; helper, 
          Expression&lt;Func&lt;TModel, TProperty&gt;&gt; expression)
      {
          var stringbuilder = new MvcHtmlString("&lt;div class='form-group'&gt;" +
                                                      helper.LabelFor(expression, new {@class = "col-sm-3 control-label"}) +
                                                      "&lt;div class='col-sm-5'&gt;" +
                                                          helper.TextBoxFor(expression, new {@class = "form-control"}) +
                                                      "&lt;/div&gt;" +
                                                "&lt;/div&gt;");
  
          return stringbuilder;
      }
  </code></pre>
  
  <p>Which can then be called as follows:</p>
  
  <p><code>@FormHelpers.MyTextBoxFor(Html, x =&gt; x.Name)</code></p>
  
  <p>However this does not appear to work for checkboxfor:</p>
  
  <p><code>Error  1   'System.Web.Mvc.HtmlHelper&lt;TModel&gt;' does not contain a definition for 'CheckBoxFor' and the best extension method overload 'System.Web.Mvc.Html.InputExtensions.CheckBoxFor&lt;TModel&gt;(System.Web.Mvc.HtmlHelper&lt;TModel&gt;, System.Linq.Expressions.Expression&lt;System.Func&lt;TModel,bool&gt;&gt;)' has some invalid arguments</code></p>
  
  <p>If I change <code>TProperty</code> to <code>bool</code> it will then compile, but I get a runtime error on the line where I call this helper:</p>
  
  <p><code>CS0411: The type arguments for method 'CollectionSystem.Helpers.FormHelpers.MyCheckboxFor&lt;TModel,TProperty&gt;(System.Web.Mvc.HtmlHelper&lt;TModel&gt;, System.Linq.Expressions.Expression&lt;System.Func&lt;TModel,bool&gt;&gt;)' cannot be inferred from the usage. Try specifying the type arguments explicitly.</code></p>
  
  <p>Can someone advise how I can go about wrapping the CheckboxFor function please.</p>