Home › Forums › General Issues › Storing repeater values as one single array in the database › Reply To: Storing repeater values as one single array in the database
I could always generate the array after save and then delete the repeater, but it seems a bit messy :
add_action('save_post', 'save_repeater_as_array');
function save_repeater_as_array($post_id) {
$repeater = get_field('my_repeater', $post_id);
$json = json_encode($repeater);
update_field('json',$json,$post_id);
if (!empty($repeater)) {
while (delete_row('my_repeater', 1, $post_id));
}
}
Also, I’ll have to rebuild the repeater on page load with JS, but that’s okay I don’t mind putting in the work.
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.