statamic / eloquent-driver

Provides support for storing your Statamic data in a database, rather than flat files.
https://statamic.dev/tips/storing-content-in-a-database
MIT License
104 stars 75 forks source link

Split blueprints for forms #204

Closed royduin closed 3 months ago

royduin commented 1 year ago

Currently we did set the blueprints driver to "file" and disable the permissions to change them on all environments (through https://github.com/justbetter/statamic-environment-permissions) so the end user can not make blueprint changes. This is great as the customer should not make any blueprint changes to collections, taxonomies, globals, etc as changing it could case the frontend to break. And if the customer wants to add something; that should probably be visible at the frontend so a developer is needed to handle it. But.. a form blueprint is more like content.

We made it dynamic with: https://github.com/rapidez/statamic/blob/master/resources/views/page_builder/form.blade.php so the customer should be able to create their own forms.

Can we split this? So form blueprints are stored in the database and the rest in a file? Probably something with permissions also need to change within Statamic itself?

ryanmitchell commented 1 year ago

Closing as it a duplicate of https://github.com/statamic/eloquent-driver/issues/164

royduin commented 1 year ago

But that's about form submissions, not the form blueprint.

ryanmitchell commented 1 year ago

You can have all blueprints in the database or all in file. There is no distinction between the type of blueprint.

royduin commented 1 year ago

Yeah, that's the point. We'd like to split that so we can version control the blueprints of collections, globals, etc and have the form blueprints in the database as that's more like content.

ryanmitchell commented 1 year ago

Yep I understand - thats not currently possible. I'll open this back up, but being honest I'm not sure if/how it could be done.

royduin commented 1 year ago

Just to keep track of it and maybe see if other users want this as well. If we find some time we'll dig into this further.

ryanmitchell commented 12 months ago

With recent Statamic versions there is a separate permission for form blueprint editing to regular blueprint editing. Does this solve the problem for you?

royduin commented 12 months ago

That's nice but we also need that separation here: https://github.com/statamic/eloquent-driver/blob/master/config/eloquent-driver.php#L19-L23 so form blueprints can be stored in the database and all others can stay in file.

ryanmitchell commented 12 months ago

I don't think that's something this driver should support.

That said, you could do it by binding your own BlueprintRepository and amending the in() method to check for file by default, and use eloquent if the namespace is form.

https://github.com/statamic/eloquent-driver/blob/efaa724dc49ca7c8f90af8aa46ddecbb6b560c4a/src/Fields/BlueprintRepository.php#L63

royduin commented 12 months ago

I'll dig into this soon, so a PR won't be accepted?

ryanmitchell commented 12 months ago

I dont really see it that form blueprints are 'content' - to me the submissions are content, and forms are similar to collections. We've given the ability to have a split config on each repository, but within a repository itself seems quite niche.

So to answer your question I'd be leaning towards no, but I'm open to being convinced.

It may also be that this driver isnt the right place for it as it may be better as a standalone add-on for those that want that level of flexibility.

ryanmitchell commented 3 months ago

@royduin just in case you didnt get notified, it's now supported in v4.3.0 as it was requested by someone else. I guess I was wrong and people do want it to work like this!