Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x] Support fieldsets in subdirectories #9341

Open
wants to merge 12 commits into
base: 5.x
Choose a base branch
from

Conversation

duncanmcclean
Copy link
Member

@duncanmcclean duncanmcclean commented Jan 17, 2024

This pull request adds support for creating & managing fieldsets located in subdirectories. This was already kinda possible but there was a few rough edges, which this PR sorts out.

One of the rough edges was the fact you couldn't previously create a fieldset in a subdirectory in the Control Panel, you had to go in and manually create the file.

This PR fixes that so you can create fieldsets in subdirectories, using this syntax: components.team_members

Another change I've made is that fieldsets in subdirectories will be split out into separate groups on the Fieldsets Index page, like we do for namespaced fieldsets.

Here's an example of what that looks like (the "My Fieldsets" group will always be displayed first):

CleanShot 2024-01-17 at 11 38 34

One last thing I had to fix was deleting fieldsets. Previously, the FieldsetRepository@delete method was manually constructing the file path and it wasn't replacing . with /. I've adjusted this to use the fieldset's path instead which takes this into account.


Closes #3178.
Closes statamic/ideas#915.
Closes statamic/ideas#560.

@caseydwyer
Copy link
Contributor

Hey @duncanmcclean, this is a great PR! Curious if there are plans to merge this in the near-ish future?

We're using nested fieldsets in a project, and it actually seems to work for the most part, but CP access is broken (ie, throws a Undefined array key "type" in FieldTransformer::referenceFieldToVue() when trying to edit—or a create a new—fieldset. Thinking this PR might resolve that issue.

@duncanmcclean
Copy link
Member Author

Sorry, we don't have an ETA for reviewing/merging this pull request. We'll get to it when we can.

In the meantime, you can pull this PR into your project with a composer patch.

@caseydwyer
Copy link
Contributor

No problem and no rush, just thought I'd check—thanks Duncan, appreciate the update!

…ubdirectories

# Conflicts:
#	resources/js/components/fieldsets/CreateForm.vue
#	src/Http/Controllers/CP/Fields/FieldsetController.php
@duncanmcclean duncanmcclean changed the base branch from 4.x to 5.x May 13, 2024 11:38
@duncanmcclean duncanmcclean changed the title [4.x] Support fieldsets in subdirectories [5.x] Support fieldsets in subdirectories May 13, 2024
@JorisOrangeStudio
Copy link

Hi Duncan,

I just ran into a small issue regarding this PR that I want to highlight here.

When selecting content.yaml here in the 'Link a single field' option, it throws this error. This is not happening when content-root.yaml is selected.
image

image

Structure:

fieldsets/
├── elements/
│   └── content.yaml
└── content-root.yaml

When using 'Link a fieldset' instead of the single field it is working as expected.

@duncanmcclean
Copy link
Member Author

Thanks @JorisOrangeStudio - should be fixed now!

@JorisOrangeStudio
Copy link

Thanks @JorisOrangeStudio - should be fixed now!

Thanks! In the Statamic core it is currently already possible to add fieldsets in subdirectories, only the namespace get prefixed and the listing in the CP is still all combined. I found out that abovr issue (to import a 'subdirectoried' single field) throws the same error without this patch installed. Should I make an issue for this, or can te latest commit also be used to fix this in core (if this PR gets merged)?

@duncanmcclean
Copy link
Member Author

In the Statamic core it is currently already possible to add fieldsets in subdirectories, only the namespace get prefixed and the listing in the CP is still all combined.

It only really works by fluke right now, it's never been intentionally supported until this PR.

or can te latest commit also be used to fix this in core (if this PR gets merged)?

Yes, the latest commit will fix it.

@johncarter-
Copy link
Contributor

Could you consider adding a description field for fieldsets for display within the CP? It would be used to explain how a fieldset should be used within the blueprints.

@duncanmcclean
Copy link
Member Author

Could you consider adding a description field for fieldsets for display within the CP? It would be used to explain how a fieldset should be used within the blueprints.

We could do that in a separate PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Subfolders / groups for fieldsets FR: Support Fieldsets in folders Fieldsets in sub-directories
4 participants