title: How to disable input field's autocomplete with EditorFor?
body: <pre><code>&lt;%= Html.EditorFor(product =&gt; product.Name) %&gt;
  </code></pre>
  
  <p>I need the generated output to have autocomplete="off" attribute set.</p>
  
  <p>What I'm missing?</p>
  
  <p>Edit:
  I'm looking an extension method for EditorFor that accepts key/value dictionary for attributes, so I can call it like this: <code>&lt;%= Html.EditorFor(product =&gt; product.Name, new { autocomplete = "off" } ) %&gt;</code></p>
  
  <p>Here it is done for LabelFor, but it is needed to be adjusted for EditorFor</p>
  
  <pre><code>    public static MvcHtmlString LabelFor&lt;TModel, TValue&gt;(this HtmlHelper&lt;TModel&gt; html, Expression&lt;Func&lt;TModel, TValue&gt;&gt; expression, object htmlAttributes) {
          return LabelFor(html, expression, new RouteValueDictionary(htmlAttributes));
      }
      public static MvcHtmlString LabelFor&lt;TModel, TValue&gt;(this HtmlHelper&lt;TModel&gt; html, Expression&lt;Func&lt;TModel, TValue&gt;&gt; expression, IDictionary&lt;string, object&gt; htmlAttributes)
      {
          ModelMetadata metadata = ModelMetadata.FromLambdaExpression(expression, html.ViewData);
          string htmlFieldName = ExpressionHelper.GetExpressionText(expression);
          string labelText = metadata.DisplayName ?? metadata.PropertyName ?? htmlFieldName.Split('.').Last();
          if (String.IsNullOrEmpty(labelText))
          {
              return MvcHtmlString.Empty;
          }
  
          TagBuilder tag = new TagBuilder("label");
          tag.MergeAttributes(htmlAttributes);
          tag.Attributes.Add("for", html.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldId(htmlFieldName));
          tag.SetInnerText(labelText);
          return MvcHtmlString.Create(tag.ToString(TagRenderMode.Normal));
      }
  </code></pre>
  
  <p>Edit2:
  I realized it can't be named EditorFor because there already exists an overridden EditorFor that accepts an anonymous type, see here <a href="http://msdn.microsoft.com/en-us/library/ff406462.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/ff406462.aspx</a>.. anyway, we can name it differently, no biggies.</p>