I have a small question regarding apostrophe-forms. You are saying that: "By default, submissions are saved to a new MongoDB collection, aposFormSubmissions
".
Is there a way to show submissions in admin bar, are they eventually only hidden?
So what would be the easiest solution to show the aposFormSubmissions
collection in admin bar?
Based on your use case description (using the reverseJoin
feature, you are thinking of form submissions as pieces, full featured content. Form submissions are extremely simple database documents without that functionality.
End of the simple answer.
You could add your own submission piece type that would associate a piece with an aposFormsSubmissions
document. It would be hard to directly create pieces with all the form submission information, since the whole point of Apostrophe Forms is the varying fields. But a new piece type could store the form submission doc's ID, along with minimal identifying information.
self.on('submission', 'createSubmissionPiece', async function(req, form, data) {
// Insert a new doc of the `form-submission` type.
});
I would then add a required field to the forms themselves to identify what field should be used as that human-readable identifier (e.g., email address). The createSubmissionPiece
event handler would use that field's value, in addition to a timestamp, to set a title on the piece.
In that case, when you wanted to use the submission data you would make a request to the aposFormSubmissions
collection to get the actual submission data.
From there you can get as fancy as you want, or use your own variation on the general idea.