Home › Forums › Add-ons › Options Page › Using acf/load_field to populate values? › Reply To: Using acf/load_field to populate values?
First, before you run into other issues, your field keys must start with "field_"
. You will have issues with using "subfield_"
. This is in the documentation, but not prominent.
What you want to do is use an acf/load_value filter https://www.advancedcustomfields.com/resources/acf-load_value/ applied to the repeater. First test to see if the value is empty. If the value is an array then values have already been saved to the field. If the value is empty then nothing has been saved yet and you can populate the repeater.
To populate the repeater with defaults you need to construct an array for the repeater values using the field keys.
$repeater = array(
// nested array for each row
array(
// field key => value pairs for each sub field
'field_12345' => 'value for the sub field',
'field_34567' => 'value for the sub field'
)
// start next row
)
Let me know if you have any questions.
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.