Home › Forums › Add-ons › Repeater Field › Saving Data with Repeater Field / ACF API
Hello,
Thanks for the great plugin. I am trying to use the Repeater Field Addon with one of my custom plugins. Pretty much, when installing my plugin, I would like to register a predefined repeater field and have an admin user modify the data. I very easily was bale to register and display the repeater field in the admin but none of the data is being saved after submitting the post. I assume there must be some type of save function I need to call as well? Could you please point me in the right direction on how to accomplish this? Here is my register code:
public function create_acf_field_repeater(){
if(function_exists(“register_field_group”))
{
register_field_group(array (
‘id’ => ‘acf_pages’,
‘title’ => ‘pages’,
‘fields’ => array (
array (
‘key’ => ‘field_53bafa11cf1de’,
‘label’ => ‘tweets’,
‘name’ => ‘tweets’,
‘type’ => ‘repeater’,
‘sub_fields’ => array (
array (
‘key’ => ‘field_53bafa19cf1df’,
‘label’ => ‘tweet’,
‘name’ => ‘tweet’,
‘type’ => ‘text’,
‘column_width’ => ”,
‘default_value’ => ”,
‘placeholder’ => ”,
‘prepend’ => ”,
‘append’ => ”,
‘formatting’ => ‘html’,
‘maxlength’ => ”,
),
array (
‘key’ => ‘field_53bafa41cf1e0’,
‘label’ => ‘json’,
‘name’ => ‘json’,
‘type’ => ‘text’,
‘column_width’ => ”,
‘default_value’ => ”,
‘placeholder’ => ”,
‘prepend’ => ”,
‘append’ => ”,
‘formatting’ => ‘html’,
‘maxlength’ => ”,
),
array (
‘key’ => ‘field_53bb06882fce4’,
‘label’ => ‘approved’,
‘name’ => ‘approved’,
‘type’ => ‘checkbox’,
‘column_width’ => ”,
‘choices’ => array (
1 => ‘approved’
),
‘default_value’ => 1,
‘layout’ => ‘vertical’,
),
),
‘row_min’ => ”,
‘row_limit’ => ”,
‘layout’ => ‘table’,
‘button_label’ => ‘Add Row’,
),
),
‘location’ => array (
array (
array (
‘param’ => ‘post_type’,
‘operator’ => ‘==’,
‘value’ => ‘page’,
‘order_no’ => 0,
‘group_no’ => 0,
),
),
),
‘options’ => array (
‘position’ => ‘normal’,
‘layout’ => ‘no_box’,
‘hide_on_screen’ => array (
),
),
‘menu_order’ => 0,
));
}
}
Thanks!
– Eric K
I realized that I had to use register_field_group within the admin_init hook for it to work. Hope this helps someone else.
The topic ‘Saving Data with Repeater Field / ACF API’ is closed to new replies.
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.