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

Fieldsets in sub-directories #3178

Open
jacksleight opened this issue Jan 30, 2021 · 2 comments · May be fixed by #9341
Open

Fieldsets in sub-directories #3178

jacksleight opened this issue Jan 30, 2021 · 2 comments · May be fixed by #9341

Comments

@jacksleight
Copy link
Contributor

Bug Description

I'm not sure if this is a bug or a side-effect of something that's not supported but almost works by accident.

If you create a fieldset in a subdirectory, such as /resources/fieldsets/components/image.yaml, it appears in the UI with the handle components.image, and you can use it elsewhere correctly. However:

  1. Although the fields function perfectly in the CP, on the frontend the values are not converted to Value objects
  2. If you try to edit it in the CP it gets saved to a different location: /resources/fieldsets/components.image.yaml
  3. it does not appear to be possible to create a subdirectory fieldset in the CP, as the . and / characters are invalid

I realise this is probably just an unsupported feature, but as the CP does almost handle it correctly I thought it could be a bug. If it is unsupported, it would be a very useful feature to add.

How to Reproduce

Values issue

  1. Create a /resources/fieldsets/components/image.yaml file
  2. Use it in a Bard field
  3. Check the field values on the frontend, they're not Value objects

File issue

  1. Create a /resources/fieldsets/components/image.yaml file
  2. Go into the CP and edit and save it
  3. Check for /resources/fieldsets/components.image.yaml file

Screenshot 2021-01-30 at 16 25 36
Screenshot 2021-01-30 at 16 25 53

Environment

Statamic 3.0.40 Solo
Laravel 8.25.0
PHP 7.3.16
local/extensions dev-main

Install method (choose one):

  • Existing Laravel app
@duncanmcclean
Copy link
Member

Yeah, it sounds like fieldsets in sub directories aren't supported yet. However, it's probably not a massive effort to actually add support for it, by the sounds of it.

@aerni
Copy link
Contributor

aerni commented Aug 12, 2021

I also found, that the find and exists methods in Statamic\Fields\FieldsetRepository will actually look for a subfolder path. The following will only return true if the fieldset exists at fieldsets/components/image.yaml. It will return false if it's fieldsets/components.image.yaml.

Fieldset::setDirectory(resource_path('fieldsets'))->exists('components.image');

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

Successfully merging a pull request may close this issue.

4 participants