goldnead / statamic-collapse-fieldtype

A Collapse-Fieldtype for Statamic to beautifully hide and show your fields.
MIT License
2 stars 3 forks source link

UI not loading when using a Grid fieldtype #1

Open taylorcammack opened 2 years ago

taylorcammack commented 2 years ago

Seems to not know how to handle using a Grid fieldtype. Just started using this add-on to test it out for a project, so not sure if this is something that used to work.

Screen Shot 2022-07-06 at 9 37 14 AM

pdipatrizio commented 2 years ago

FWIW, I'm having the same issue.

goldnead commented 2 years ago

Thanks @taylorcammack for reporting this issue and sorry for holding back on my end for so long. This was definitely something that used to work. I suspect, that it broke with some of the recent Statamic Updates.

I'm on it as I need this feature for one of my current projects as well.

pdipatrizio commented 1 year ago

@taylorcammack I just stumbled on this Statamic PR and it reminded me of this Collapse Fieldtype issue. Figured I'd share here in case it's related.

jasonvarga commented 1 year ago

Hey guys. Sorry but it's not related.

Looks like your problem here is because you aren't providing the 'meta' data properly to the sub fields.

https://github.com/goldnead/statamic-collapse-fieldtype/blob/2d555cace5e967d755d39bfdc10498b082bc508d/resources/js/fieldtypes/Collapse.vue#L20

https://github.com/goldnead/statamic-collapse-fieldtype/blob/2d555cace5e967d755d39bfdc10498b082bc508d/src/Fieldtypes/Collapse.php#L52-L60

mattpfeffer commented 1 year ago

Just to add to the above, running into the same issue with a replicator field. Getting an undefined array key in my stacktrace:

Undefined array key "field" {"userId":"....","exception":"[object] (ErrorException(code: 0): Undefined array key \"field\" at .../vendor/statamic/cms/src/Fields/Fields.php:235)
goldnead commented 1 year ago

Hey guys. Sorry but it's not related.

Looks like your problem here is because you aren't providing the 'meta' data properly to the sub fields.

https://github.com/goldnead/statamic-collapse-fieldtype/blob/2d555cace5e967d755d39bfdc10498b082bc508d/resources/js/fieldtypes/Collapse.vue#L20

https://github.com/goldnead/statamic-collapse-fieldtype/blob/2d555cace5e967d755d39bfdc10498b082bc508d/src/Fieldtypes/Collapse.php#L52-L60

Do you have any idea where I could find a reference for a properly provided meta field @jasonvarga ? Didn't have any luck yet while tinkering around and looking for any examples that solve the same issue.

mattpfeffer commented 1 year ago

Hey guys. Sorry but it's not related. Looks like your problem here is because you aren't providing the 'meta' data properly to the sub fields. https://github.com/goldnead/statamic-collapse-fieldtype/blob/2d555cace5e967d755d39bfdc10498b082bc508d/resources/js/fieldtypes/Collapse.vue#L20

https://github.com/goldnead/statamic-collapse-fieldtype/blob/2d555cace5e967d755d39bfdc10498b082bc508d/src/Fieldtypes/Collapse.php#L52-L60

Do you have any idea where I could find a reference for a properly provided meta field @jasonvarga ? Didn't have any luck yet while tinkering around and looking for any examples that solve the same issue.

I think I actually have put together a solution for this in my own project, do you mind if I submit a pull request?

goldnead commented 1 year ago

@mattpfeffer please go ahead! I'm curious how you solved it :) Thanks!

pdipatrizio commented 1 year ago

@mattpfeffer very curious how you solved it as well. I spun my tires for the better part of a week trying to figure it out.

redyja commented 1 year ago

The same happens when you try to use a bard field in the Collapse Fieldtype

goldnead commented 1 year ago

The same happens when you try to use a bard field in the Collapse Fieldtype

Yeah, it happens with all structured data fields. I just have no idea how to solve it. Burnt a few hours already, so I'm happy for any hints :)

goldnead commented 1 year ago

Hey guys, just wanted to post an update on this one. Still no luck, getting it fixed. As @jasonvarga mentioned I narrowed it down to the passing of the meta fields. I just can't get my head around, how to fix this as no documentation exists (it's really edge-casy to be fair). I figured out how to solve the loading-indicator, but now I get another error TypeError: Cannot read properties of undefined (reading 'text_field') when trying to include a Grid Fieldtype into the collapse. I couldn't figure out how statamic expects the meta data to be passed down into structured fieldtypes. I'm glad for anyone to help on this one, as it is an important feature for such a "lightweight" addon.