soflyy / breakdance-bugs

Bug reports from Breakdance users.
40 stars 6 forks source link

V2RC1 ACF Dynamic Data using Post Object field > Custom Field returns incorrect format #1127

Open DigitalServicesLab opened 1 month ago

DigitalServicesLab commented 1 month ago

When using the Post Object field for a dynamic data source, the option to manually use a ACF field key always returns the data direct from the database, not in the 'return format' defined by ACF.

In the below example, the ACF field people_profile_photo is configured to return an image url. BD is returning the image ID (this can be seen if you use the dynamic data on a text field)

image

DigitalServicesLab commented 1 month ago

Having thought about this further, I guess this isn't a bug in as much as the custom field key chosen could be any field and BD doesn't know it's an ACF field - despite the fact its a sub field/child field of an ACF Post Object field.

This probably needs a checkbox to state 'this is an ACF' field and BD uses its ACF methods to return it. Or additional, use some contextual logic to understand what's being returned or what's needed... in this case the dynamic data is on an image element, so you'd expect it to know it needs an image url (or image atts array), but the return format is controlled by the PostField field Class which just returns a string... always.

As an aside from that, there doesn't seem to be a way to return a literal image url string to an image element from a custom field either. I used the ACF 'acf/save_post' action to save the actual image url in a separate meta field after ACF saved the image id but even if I use that as the field key, it still doesn't work, so what is the correct format required for a dynamic image data? When selecting dynamic data options, it says 'image url' but that obviously isn't really what it is returning or at least it wants it in a very specific format or needs to process it before it gets it. I tried:

none of this works.

In a nutshell - Post Object fields have limited use with custom fields, unless some context awareness is included, or ACF field logic is included. Otherwise its usefulness extends only to text data.

DigitalServicesLab commented 1 month ago

Given that a Post Object field provides access to another Post (not the current global post), I think the best solution would be to provide access to the normal Dynamic Data field selection screen but in the context of the post of the Post Object.

So select dynamic data > Post Object field And then in the options for that have another button that opens the dynamic data screen again but now you are selecting the field for the post object... makes more sense than having a limited drop down of text fields or custom keys to select from.