Search code examples
apostrophe-cms

ApostropheCMS error during editor modal save when joining a piece to a module


I created a new "modal" piece where I'm joining another module (so I can display modules inside the modal). I can select the module in the editor modal, but when I save I get this error pop up: An error occurred. Please try again later. Front-end console shows this is coming from /modules/apostrophe-browser-utils/js/always.js

All I have is the /lib/modules/modal/index.js file like this:

module.exports = {
    extend: "apostrophe-pieces",
    name: "modal",
    label: "Modal",
    seo: false,
    addFields: [
      {
        name: "_image",
        type: "joinByOne",
        withType: "apostrophe-image",
        label: "Pick an image",
        required: true,
        idField: "_id",
        filters: {
          // Thought maybe not having a projection was an issue. didn't help
          projection: {
            attachment: 1
          }
        }
      }
    ]
  };

Screen Cap: https://screencast.com/t/OGQOD0PiG


Solution

  • the idField name is conflicting with the default id property all apostrophe docs have. Change it to something like imageId. In all cases EXCEPT _id, the _ prefix in apostrophe indicates a property that is 'filled in' by apostrophe at some point, and not actually saved with the doc.