3

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?

Larry Ruckman
  • 83
  • 2
  • 8
  • Why do you want it on the part? Why isn't this a property of the part rather than a field? – Bertrand Le Roy Jan 07 '14 at 09:14
  • Good question, if it's a property on the part then I control the interface, correct? I assumed that it was done this way (as a field) to allow the built-in Orchard controls to take over (display / storage). – Larry Ruckman Jan 07 '14 at 14:56
  • Can anyone point me at a good reference for this? All I've found are questions with incomplete exampled. – Larry Ruckman Jan 07 '14 at 18:35

1 Answers1

0

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

Larry Ruckman
  • 83
  • 2
  • 8