eloquent-driver icon indicating copy to clipboard operation
eloquent-driver copied to clipboard

Split blueprints for forms

Open royduin opened this issue 2 years ago • 11 comments

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?

royduin avatar Sep 15 '23 13:09 royduin

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

ryanmitchell avatar Sep 15 '23 13:09 ryanmitchell

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

royduin avatar Sep 15 '23 13:09 royduin

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

ryanmitchell avatar Sep 15 '23 13:09 ryanmitchell

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.

royduin avatar Sep 15 '23 13:09 royduin

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.

ryanmitchell avatar Sep 15 '23 13:09 ryanmitchell

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.

royduin avatar Sep 15 '23 14:09 royduin

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

ryanmitchell avatar Oct 11 '23 05:10 ryanmitchell

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.

royduin avatar Oct 11 '23 06:10 royduin

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

ryanmitchell avatar Oct 11 '23 06:10 ryanmitchell

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

royduin avatar Oct 11 '23 07:10 royduin

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 avatar Oct 11 '23 07:10 ryanmitchell