I want to disable web editing for a field being displayed while using Html.Sitecore().Field(string fieldName, Item item, object params)
but I am having trouble. The following throws a "parameter count mismatch" error
@Html.Sitecore()
.Field(item.InnerField.Name, item.InnerField.Item,
new Sitecore.Collections.SafeDictionary<string, string>
{
{"class", classParam},
{"disable-web-edit", pageEditorEnabled.ToString()}
});
I couldn't use an anonymous object because disable-web-edit has hyphens. There may be some other keyword that I'm supposed to be using but that's what field renderer uses iirc.
[TargetParameterCountException: Parameter count mismatch.]
System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +14255904
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +96
System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index) +37
Sitecore.Mvc.Helpers.TypeHelper.CopyProperties(Object source, SafeDictionary`2 target) +89
Sitecore.Mvc.Helpers.SitecoreHelper.BeginField(String fieldName, Item item, Object parameters) +120
Sitecore.Mvc.Helpers.SitecoreHelper.Field(String fieldName, Item item, Object parameters) +23
Try to use DisableWebEdit
in anonymous object like that:
@Html.Sitecore().Field("Field Name", new { DisableWebEdit = true })
You can also set mw = 300, mh = 200
for the image fields.
I don't know if there are any other options supported out of the box.
Anything that will not be recognized in the field render pipeline, will be added to the tag as an HTML attribute.