编辑零件时显示MediaLibraryPickerField [英] Display MediaLibraryPickerField when editting a part
问题描述
我在这里丢失了一些东西,无法终生弄清楚是什么.
I'm missing something here and can't for the life of me figure out what.
我已将MediaLibraryPickerField添加到我创建的部件中:
I've added a MediaLibraryPickerField to a part I created:
ContentDefinitionManager.AlterPartDefinition(typeof (FloorPlanPart).Name, cfg => cfg
.WithField("Photo", f => f
.OfType("MediaLibraryPickerField")
.WithDisplayName("Photo")
.WithSetting("MediaLibraryPickerFieldSettings.Required", "true")));
我可以验证此字段是否已正确添加到我的部件中.这部分属于自定义类型:
I can verify that this field has been added correctly to my part. This part belongs to a custom type:
ContentDefinitionManager.AlterTypeDefinition("FloorPlan", cfg => cfg
.WithPart(typeof(FloorPlanPart).Name)
.Creatable()
.Draftable(false));
我已设置驱动程序以在编辑时返回以下内容:
I have my driver setup to return the following on an edit:
protected override DriverResult Editor(FloorPlanPart part, dynamic shapeHelper)
{
return ContentShape("Parts_FloorPlan_Edit",
() => shapeHelper.EditorTemplate(
TemplateName: "Parts/FloorPlan",
Model: part,
Prefix: Prefix));
}
我的编辑视图如下所示:
my edit view looks like the following:
@using System.Web.Mvc.Html
@model Models.FloorPlanPart
<fieldset>
<legend>Floor Plan Fields</legend>
<div class="editor-label">@Html.LabelFor(x => x.FloorPlanName)</div>
<div class="editor-field">
@Html.EditorFor(x => x.FloorPlanName)
@Html.ValidationMessageFor(x => x.FloorPlanName)
</div>
</fieldset>
有些地方媒体选择器应该显示,但是在创建新的平面图时却不会显示.我所得到的只是我部分中的字段(FloorPlanName).如何显示媒体选择器?如果我将媒体选择器添加为内容类型的字段,则它确实会显示,但我是否也应该以这种方式来做到这一点?
Some where along the line the Media picker is supposed to show up but never does when creating a new Floor Plan. All I get is just the fields in my part (FloorPlanName). How do I get the media picker to show? If I add the Media picker as a field on my content type it does show but shouldn't I be able to do it this way as well?
推荐答案
菜鸟错误,我以为我使用的是最新版本的Orchard 1.7.2,但使用的是1.6.2.
Rookie mistake, I thought I was using the latest version of Orchard 1.7.2 but was using 1.6.2.
这篇关于编辑零件时显示MediaLibraryPickerField的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!