Display MediaLibraryPickerField when editting a part

你离开我真会死。 提交于 2019-12-12 15:09:57

问题


I'm missing something here and can't for the life of me figure out what.

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>

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?


回答1:


Rookie mistake, I thought I was using the latest version of Orchard 1.7.2 but was using 1.6.2.



来源:https://stackoverflow.com/questions/20962487/display-medialibrarypickerfield-when-editting-a-part

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!