Home › Forums › Add-ons › Options Page › Using acf/load_field to populate values? › Reply To: Using acf/load_field to populate values?
Well in my case I am using acf/load_field to load form fields dynamically for each post in a loop, similar to this example:
if( $loop->have_posts() ):
while( $loop->have_posts() ): $loop->the_post();
$id = get_the_ID();
if( function_exists('acf_add_local_field_group') ):
acf_add_local_field_group(array(
'key' => 'field_product_item_' . $id,
'title' => 'Product Item #' . $id,
'fields' => array(
array(
'key' => 'field_product_item_group_' . $id,
'type' => 'group',
'sub_fields' => array()
//... dynamic items with default values will be added to this sub_field using acf/load_field
)
)
);
add_filter('acf/load_field/key=field_product_item_group_' . $id, 'load_product_details_form', 20, 3);
So this approach seems to work so far. Anyway I hope this is not prone to problems in the future.
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.