Support

Account

Home Forums Add-ons Flexible Content Field Populate Flexible Content Rows Programmatically Reply To: Populate Flexible Content Rows Programmatically

  • Hi @circlecube

    The flexible content field will create a random ID for the newly generated layout, so it will be hard to target it. What you can do is using the append action mentioned in this page: https://www.advancedcustomfields.com/resources/adding-custom-javascript-fields/.

    I think you can also target the last layout after adding the new layout. This is what I tested in the console:

    jQuery(".acf-field-1234567890abc .layout[data-layout='my_layout_name']:last input[id$='field_abc1234567890']").val("test")

    Where “acf-field-1234567890abc” is the flexible content and “field_abc1234567890” is the custom field in the layout.

    I hope this makes sense.