Skip Navigation

[Resolved] Saving a dynamically populated select box in a repeating group

This support ticket is created 6 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 1 reply, has 2 voices.

Last updated by Christian Cox 6 years, 6 months ago.

Assisted by: Christian Cox.

Author
Posts
#948409

Hello,

I am using the following code to populate a select dropdown box on a CPT and it works fine when a choice is made and the post saved.

add_filter( 'wpt_field_options', 'func_dynamic_populate', 10, 3);
function func_dynamic_populate( $options, $title, $type ){
    switch( $title ){
        case 'People ID':
            $options = array();
            $args = array(
                'post_type'        => 'people',    // change post type slug here if needed
                'post_status'      => 'publish');
            $posts_array = get_posts( $args );
            foreach ($posts_array as $post) {
                $options[] = array(
                    '#value' => $post->ID,
                    '#title' => $post->post_title,
                );
            }
            break;
    }
    return $options;
}

However if I use the select box within a repeating group it doesn't save the choice made. Is there any code that I can add to the above to make it work within a repeating group?

Thanks in advance,
Adam

#948505

Hi, actually the wpt_field_options filter is no longer supported and is not expected to work with new features like Repeating Field Groups. Unfortunately there is not a good way to create dynamic field inputs in the current system. If you'd like to request an improvement to our API and filters that will allow you to create dynamic field inputs that work in repeating field groups, feel free to submit a ticket using the "Suggest an improvement" feature here in the forums. For now, the only way to manage these options is to manual management in wp-admin.