This is a bit of rabbit hole but I’m hoping someone has trod this way before. I am using Flexible Content to offer the Editor access to a number of Blocks (think Gutenberg but ACF). Most of these blocks are content blocks and I can give them an intelligent title ‘Text Block’, ‘Heroes’ etc. but in order to insert preformed blocks in the run of the page I have a Layout called ‘Block Selector’ in which the Editor can choose from a Select; ‘Contact Form’, ‘Team’ etc.
When the Layouts are collapsed, they all show the Layout Name
What I would like to do is append the Selection (which is the value of the first (Select) field in the layout) to the title “Block Selector”, so “Block Selector: Contact Form” etc.
Can anyone point me at the hook where I can get into the Layout Title?
Or, I guess, a clue to how I could target these things in jQuery ‘change’ events
Start here https://www.advancedcustomfields.com/resources/dynamically-populate-a-select-fields-choices/
You would have to loop over all of the layouts in the flex field to populate the select field.
I can’t give you any help on dynamic population would work as new layouts are created, not something I’ve ever tried before. But it would involve creating a JS action that triggers when a layout is added or when the field you’re basing it on changes and then writing JS to update the select field(s) choices.
Targeting events on ACF fields would look something like
$('[data-key="field_XXXXXXX"] .acf-field select')