Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple field forget about limit on refresh #15

Open
AndreaBarghigiani opened this issue Jul 29, 2019 · 0 comments
Open

Multiple field forget about limit on refresh #15

AndreaBarghigiani opened this issue Jul 29, 2019 · 0 comments

Comments

@AndreaBarghigiani
Copy link

Hi there,
I just want to discuss a strange problem I met working with this amazin code. I use it frequently but I've noticed a strange behaviour in a new project I am working on.

Basically the first time I set the featured posts all is working great and the limit is respected but when I refresh the page and I hit save again I get my selection added again as you can see from the image below:

fields-added

I've also recorded a short video to show you how the field is behaving. The load spinner is too big but the main issue is that the first time I load the search field I am able to respect my limit but when it gets reloaded I will be able to select new items and if I hit save, even if I do not select anything, the selection increases as in the image above.

The following is the code I am testing and I have this problem in a main option page and also in a WooCommerce Products sub-menu page (this is the reason for the commented lines).

<?php
	$prefix = '_hbeer_';
	
	$hbeer_featured = new_cmb2_box(
		array(
			'id' => $prefix . 'beer_settings',
			'title' => __( 'Scegli birre', 'hbeer-text' ),
			'object_types' => array( 'options-page' ),
			// 'parent_slug' => 'edit.php?post_type=product',
			// 'option_key'   => $prefix . 'fbeers',
		)
	);

	$hbeer_featured->add_field(
		array(
			'name' => __( 'Scegli birre', 'hbeer-text' ),
			'id' => $prefix . 'featured_beers',
			'type' => 'post_ajax_search',
			'multiple' => true,
			'limit' => 6,
			'sortable' => true,
			'query_args' => array(
				'post_type' => [ 'product' ],
				'posts_per_page' => -1,
			),
		)
	);

	cmb2_metabox_form( $prefix . 'beer_settings', 'hbeer-settings' );

Are you able to give me a heads ups on why this is happening? I've recently cloned your repo and changed all the files involved with its use but the problem is still happening.

Thank you in advance for the future help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant