ponzu-cms / ponzu

Headless CMS with automatic JSON API. Featuring auto-HTTPS from Let's Encrypt, HTTP/2 Server Push, and flexible server framework written in Go.
https://docs.ponzu-cms.org
BSD 3-Clause "New" or "Revised" License
5.67k stars 387 forks source link

Add "single form content" option when creating a new content #324

Closed MattiaCostamagna closed 4 years ago

MattiaCostamagna commented 4 years ago

This is a feature request. I don't know if it's currently possible (I haven't found it anywhere in the docs, so I guess it's not), but it would be nice to have contents that are not made of a list of data, but instead a single form.

A practical use of it could be a content that contains the contact information form (telephone, address, email, etc.), so the content has just those fields and it's limited to one entry that you can edit but not duplicate or create a new one.

I'm new to ponzu (and I'm loving it) and I'm making a simple showcase website for a company, so I don't know where I should put all those information without risking that the person that will manage the data will create a duplicate.

olliephillips commented 4 years ago

I can see the use case, for sure.

Not as elegant, but still functional, what about using the built-in hooks to prevent further edits/additions on your content type?

If you implement the interface(s) for your item once you've set the content up, returning any error will prevent any default operation, allowing you to effectively write-protect that content type.

You might check also the content type id being edited, and only allow save if it is the single record you want in Ponzu, stopping people adding more records.

Check out the documentation here:

https://docs.ponzu-cms.org/Interfaces/Item/#itemhookable

MattiaCostamagna commented 4 years ago

Thank you for the fast reply!

That might work for me, the only issue I see is that it's not very user friendly for my client. I'll follow your advice, but please take this into consideration as a possible feature for a future release.

Thanks!

nilslice commented 4 years ago

@MattiaCostamagna - thanks for the feedback and the suggestion! I understand your concern over the client's potential to create a new record instead of updating an existing one. However, this is pretty common practice in CMS use. I wouldn't expect a reasonably savvy CMS user to mistakenly create a new record instead of simply updating an existing one.

I don't think it is likely that this would be introduced as a feature, unless there is another high-value use case it supports.