Closed morhi closed 1 year ago
I'd love to have a way to do this too. Related: https://github.com/statamic/ideas/issues/698
Without thinking about it too deeply, this sounds like a good solution. But could you please continue the conversation in statamic/ideas#698 instead? It's the same feature request.
Thanks!
Bug description
I created a custom fieldtype which holds an array of fields:
If
fields
contains anAsset
fieldtype the stored asset path in an entry will not be changed when renaming the file behind the asset. This is due to a limitation insrc/Data/DataReferenceUpdater.php
which only updates nested fields if the fieldtype isreplicator
,grid
orbard
. It makes sense, because the nested fields are collected in a specific way depending on the fieldtype insideDataReferenceUpdater
.This is my suggestion to fix it:
1) Create a new contract called
HasNestedFields
. This contract has a methodnestedFields(): array
. 2) The fieldtypesGrid
,Replicator
andBard
need to implement the new contract 3) The new method must return an array of nested fields based on the logic of theupdate*Children
method ofDataReferenceUpdater
4) TheDataReferenceUpdater
now checks whether the fieldtype has implemented the interface instead of checking a specific filedtype 5) TheDataReferenceUpdater
calls thenestedFields()
method of the fieldtype instead of collecting the nested fields on its own.What do you think? If it this sounds good I'll try to find some spare time for this fix next week. It would be very nice for me to have this fixed :)
How to reproduce
fields
type for adding subfieldsAsset
field to the subfieldsLogs
No response
Environment
Installation
Fresh statamic/statamic site via CLI
Antlers Parser
runtime (new)
Additional details
No response