Hi, I see a couple of answers to the same issue here but I’m not having much luck - I hope someone would kindly have a quick look over my code and see if they can spot anything untoward… It’s driving me mental!
There is an alternate method as well, which uses one filter rather than 4, which also works (it’s a newer and more efficient method than the 4 filters were previously):
Be sure you use either this last filter, or all four of the others, and then test your code and dynamic population again. Let us know how that turns out.
Dynamically populated drop-downs are populating fine but still not saving to the db after trying all your suggestions. Annoyingly the drop-downs are behaving as expected when using Gform ‘Preview’ option which makes me think it’s a theme/plugin issue.
I’ll nibble away at it and if I fine an obvious answer I’ll pop it on here for future ref.
A little bit more for you knowledgable gents in case you have stumbled on this before!
On my build dynamically populated drop-downs are not saving when the form is embedded on a custom post type. They are saving to the db fine on posts and pages. I’m using the same template code for posts and my CPT whilst testing this. I’ve tried the following:
With/without ‘show_in_rest’ when declaring CPT
Turning off all plugins
Switching to 2019 theme (I’m using WP Bootstrap Starter and child theme)
Please can you have a quick squint at my CPT code and let me know if I’ve missed anything out or if you have any other ideas to what I can do to test this further please?
function forms_cpt() {
$labels = array(
'name' => 'Form Pages',
'singular_name' => 'Form Page',
'add_new' => 'Add New Form Page',
'add_new_item' => 'Add New Form',
'edit_item' => 'Edit Form Page',
'new_item' => 'New Form Page',
'all_items' => 'All Forms',
'view_item' => 'View Form Pages',
'search_items' => 'Search Form Pages',
'not_found' => 'No Form Pages Found',
'not_found_in_trash' => 'No Form Pages found in Trash',
'parent_item_colon' => '',
'menu_name' => 'Form Page',
);
register_post_type( 'form-page', array(
'labels' => $labels,
'has_archive' => false,
'public' => true,
'show_in_nav_menus' => false,
'show_in_menu' => true,
'exclude_from_search' => false,
'capability_type' => 'post',
'rewrite' => array( 'slug' => 'forms-restricted' ),
'menu_icon' => 'dashicons-groups',
'supports' => array('title','editor')
)
);
}
add_action( 'init', 'forms_cpt' );
Again, many thanks in advance for any thoughts or ideas I can try