This project is read-only.

Editor template not displaying for custom part

Topics: Writing modules
May 23, 2011 at 6:02 PM
Edited May 23, 2011 at 6:21 PM

I've been racking my brain trying to figure this one out.

I've got a custom module with a part called ProjectPart which I've got added to a custom ContentType called ProjectPage (it's the only part added to the content type).

When I try to create a new ProjectPage it doesn't show the editor template pushed from the driver.

I've confirmed that the driver's code is hit, it just doesn't seem to care about the TemplateName I've provided.

When I try to hit save or publish on the Content Item, it doesn't let me because the model doesn't validate.

I can provide more details.

Drivers > ProjectDriver.cs

        protected override DriverResult Editor(ProjectPart part, dynamic shapeHelper)
            var shape = ContentShape("Parts_Project_Edit", () => shapeHelper.EditorTemplate(
                   TemplateName: "Parts/Project",
                   Model: part,
                   Prefix: Prefix));
            return shape;
        protected override DriverResult Editor(ProjectPart part, Orchard.ContentManagement.IUpdateModel updater, dynamic shapeHelper)
            updater.TryUpdateModel(part, Prefix, nullnull);
            return Editor(part, shapeHelper);

Views > EditorTemplates > Parts > Project.cshtml

@model ProjectPart
  <legend>Project Fields</legend>
  <div class="editor-label">
    @Html.LabelFor(model => model.Year)
  <div class="editor-field">
    @Html.TextBoxFor(model => model.Year)
    @Html.ValidationMessageFor(model => model.Year)
  <div class="editor-label">
    @Html.LabelFor(model => model.InvoiceNumber)
  <div class="editor-field">
    @Html.TextBoxFor(model => model.InvoiceNumber)
    @Html.ValidationMessageFor(model => model.InvoiceNumber)
May 23, 2011 at 8:17 PM


My wasn't publishing.

May 25, 2011 at 8:57 AM

Related issue: I spent about 3 hours yesterday checking all but my file was correct!  Turns out I had the wrong name for the shape type in the placement file so I was getting a blank template with just a save button in the admin.  Thank you!