Home › Forums › Add-ons › Flexible Content Field › Populate Flexible Content Rows Programmatically › Reply To: Populate Flexible Content Rows Programmatically
Yes, this makes sense. I’m able to find and target the flexible content area, but I’m not finding much success once I have that target to add more layouts or rows to that flexible content field.
It looks like I have to set the focus to that element and then the acf.fields.flexible_content object is updated and when I add elements it goes to the right place, but that doesn’t seem to be working 100%. I can set the focus with trigger.(‘focus’) or simply .focus() but it still doesn’t add them all the time. If there are multiple flexible content fields, I’m not sure how to set the acf focus to one vs the other via the script. It does seem to work however if I click the ‘add row’ button to focus on that flexible content field and then trigger my script. So I’m doing that for now, not ideal, but functional at least. Still saving quite a few clicks.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.