title: Create CheckboxFor MVC helper with title attribute from model description
body: <p>I've created a text box helper to add a title (tooltip) taken from the description attribute for the field in a model:</p>
  
  <pre><code> public static MvcHtmlString TextBoxForWithTitle&lt;Tmodel, TProperty&gt;(this HtmlHelper&lt;Tmodel&gt; htmlHelper, Expression&lt;Func&lt;Tmodel, TProperty&gt;&gt; expression, object htmlAttributes = null)
      {
          var metaData = ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData);
          string htmlFieldName = ExpressionHelper.GetExpressionText(expression);
          string textboxText = metaData.DisplayName ?? metaData.PropertyName ?? htmlFieldName.Split('.').Last();
          if (string.IsNullOrEmpty(textboxText))
              return MvcHtmlString.Empty;
          var textbox = new TagBuilder("input");
          textbox.MergeAttributes(new RouteValueDictionary(htmlAttributes));
          if (!string.IsNullOrEmpty(metaData.Description))
              textbox.Attributes.Add("title", metaData.Description);
          return MvcHtmlString.Create(textbox.ToString());
      }
  </code></pre>
  
  <p>I know the checkbox is also an 'input' type element but I have no idea how to construct a helper to use the description as a title.  </p>
  
  <pre><code> public static MvcHtmlString CheckBoxForWithTitle&lt;TModel, TProperty&gt;(this HtmlHelper&lt;TModel&gt; htmlHelper, Expression&lt;Func&lt;TModel, TProperty&gt;&gt; expression, object htmlAttributes = null)
      {
          var metaData = ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData);
          string htmlFieldName = ExpressionHelper.GetExpressionText(expression);
          string chkboxText = metaData.DisplayName ?? metaData.PropertyName ?? htmlFieldName.Split('.').Last();
          MemberExpression memberExpression = expression.Body as MemberExpression;
          string parameterName = memberExpression.Member.Name;
  
          if (string.IsNullOrEmpty(chkboxText))
              return MvcHtmlString.Empty;
          var chkbox = new MvcHtmlString(
              string.Format(
              "&lt;input type=\"checkbox\" name=\"{0}\" id=\"{0}\" value=\"{1}\" {2} /&gt;",
              parameterName, 
          chkbox.MergeAttributes(new RouteValueDictionary(htmlAttributes));
          if (!string.IsNullOrEmpty(metaData.Description))
              chkbox.Attributes.Add("title", metaData.Description);
          return MvcHtmlString.Create(chkbox.ToString());
      }
  </code></pre>