New Addon - Moderation for collections


Think is something that is missing on Cockpit when comparing with other headless solutions, the possibility to define a status on the contents and therefore affect the api calls. Resuming, let’s imagine we want to work on a post that is already visible in live (Published state) and we want to save our changes but without having them visible. So using the addon we can save as a Draft and the API will still return the previous published version.

The Addon provides a new field type (Moderation) that enhances the collection form page with a new option:


More details on the project repo:

During the implementation I faced two challenges:

  1. Having the sidebar item positioned on top of the list, the way I did it is a bit hacky (via javascript), but would be interesting if we could have a weight value that could be used to define the order of the items, or a new event on the sidebar so we can manipulate the items
  2. Get the latest revision that have a field with a specific value, I’m hooking into the collections.filter.after and if the field is present and value is draft, I load the revisions and iterate until find the correct one. It works well, but not sure if it can cause performance troubles.

Feedback appreciated.


First of all, thanks for your work!

I have question regarding a specific use case, which you can hopefully answer for me.

I want to have a website where anonymous people can submit form data to be saved in cockpit via the api. but it would be necessary that all of this posts are created as drafts, which a moderator can later publish. is this possible with cockpit and your plugin?

thank you for your help!

all the best,


Hi @malua,

yes, you can set the moderation field to Draft when creating the entry, however since the API is exposed, the users may be able to manipulate the request and change the value. You can do the following to ensure that all API requests are saved as Draft.

Handle the trigger<your_collection_name>:

// Include actions.
  $app->on('', function($name, &$entry, $isUpdate) {
    $entry['status'] = 'Draft';

so any collection named tests that is created via the rest api, the status field will be Draft, so if you try to force the field value on your post request to other than Draft it will not have any impact:

	"data": {
		"title": "some title",
		"status": "Published"

will result on status Draft


Thanks for the fast reply. This is exactly what I have been looking for!