Git Product home page Git Product logo

cmb2-field-ajax-search's People

Contributors

ko31 avatar mte90 avatar rubengc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cmb2-field-ajax-search's Issues

Unable to save the new field when I have multiple=true option

I'm trying to do some as this:


     $cmb->add_field ( array (
      'name'       => __( 'Field title', 'ges' ),
      'desc'       => __( 'Field desc', 'ges' ),
      'id'         => $prefix.'_key',
      'type'       => 'term_ajax_search',
      'multiple'   => false,
      'query_args' =>array (
         'taxonomy'=>'custom_tax',
         'childless'=>true,
         'hide_empty'		=> false
      ),
      'repeatable' => true,
     ));

But I see this error message:
Warning: array_values() expects parameter 1 to be array

I think that when repeteable=true the contents of the field in meta_value in database is serialized. It is said, all the repeteable values are in a unique record. I have an existing declaration that I want to change by this functionallity but I will lose all values if I try to do so.

It is not possible to save the same storage criteria?

Front-end Use

Hello!

Is it possible to use this on the front-end as a search input for users?

Thanks ;)

Composer Use

Hi is it possible that you create a composer version.
so i can add it as a dependencies in mine own project composer.json

Several warnings

[04-Apr-2023 11:13:10 UTC] PHP Warning:  include_once(/Users/robert/Dropbox/Websites/context.local/wp-content/plugins/cmb2-context/cmb2/includes/CMB2_Field_Ajax_Search.php): failed to open stream: No such file or directory in /Users/robert/Dropbox/Websites/context.local/wp-content/plugins/cmb2-context/cmb2/includes/helper-functions.php on line 44
[04-Apr-2023 11:13:10 UTC] PHP Warning:  include_once(): Failed opening '/Users/robert/Dropbox/Websites/context.local/wp-content/plugins/cmb2-context/cmb2/includes/CMB2_Field_Ajax_Search.php' for inclusion (include_path='.:/Applications/MAMP/bin/php/php7.4.33/lib/php') in /Users/robert/Dropbox/Websites/context.local/wp-content/plugins/cmb2-context/cmb2/includes/helper-functions.php on line 44
[04-Apr-2023 11:14:57 UTC] PHP Notice:  Trying to get property 'name' of non-object in /Users/robert/Dropbox/Websites/context.local/wp-content/plugins/cmb2-field-ajax-search/cmb2-field-ajax-search.php on line 278
[04-Apr-2023 11:15:06 UTC] PHP Warning:  Invalid argument supplied for foreach() in /Users/robert/Dropbox/Websites/context.local/wp-content/plugins/cmb2-field-ajax-search/cmb2-field-ajax-search.php on line 249

The first two were on activation.
The second two were when I searched for a value in the field.
When I tried to set the found value, the box actually displayed only its ID and not its name, and it didn't get set.

JS Error: Uncaught Error: Syntax error, unrecognized expression

Hi,

first of all thanks for the plugin.

I tried to use it within a "group" field. After selecting a value over the ajax search dropdown, Im getting this JS error message:

load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,jquery-ui-position,jquery-ui&load[]=-tooltip&ver=4.9.5:2 Uncaught Error: Syntax error, unrecognized expression: input[name=prefixdemo[0][prefixasfd]]

at Function.fa.error (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,jquery-ui-position,jquery-ui&load[]=-tooltip&ver=4.9.5:2)
at fa.tokenize (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,jquery-ui-position,jquery-ui&load[]=-tooltip&ver=4.9.5:2)
at fa.select (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,jquery-ui-position,jquery-ui&load[]=-tooltip&ver=4.9.5:2)
at Function.fa (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,jquery-ui-position,jquery-ui&load[]=-tooltip&ver=4.9.5:2)
at Function.a.find (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,jquery-ui-position,jquery-ui&load[]=-tooltip&ver=4.9.5:9)
at n.fn.init.find (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,jquery-ui-position,jquery-ui&load[]=-tooltip&ver=4.9.5:2)
at n.fn.init.a.fn.find (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,jquery-ui-position,jquery-ui&load[]=-tooltip&ver=4.9.5:9)
at a.fn.init.n.fn.init (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,jquery-ui-position,jquery-ui&load[]=-tooltip&ver=4.9.5:2)
at new a.fn.init (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,jquery-ui-position,jquery-ui&load[]=-tooltip&ver=4.9.5:9)
at n (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,jquery-ui-position,jquery-ui&load[]=-tooltip&ver=4.9.5:2)

The value not getting saved. Maybe its because of the generated input name (input[name=prefixdemo[0][prefixasfd]])?

My code is:

add_action( 'cmb2_admin_init', 'yourprefix_register_repeatable_group_field_metabox' );
/**
 * Hook in and add a metabox to demonstrate repeatable grouped fields
 */
function yourprefix_register_repeatable_group_field_metabox() {
  $prefix = 'prefix';

  /**
   * Repeatable Field Groups
   */
  $cmb_group = new_cmb2_box( array(
    'id'           => $prefix . 'metabox',
    'title'        => esc_html__( 'Recommendation Products (4)', 'cmb2' ),
    'object_types' => array( 'landingpage' ),
  ) );

  // $group_field_id is the field id string, so in this case: $prefix . 'demo'
  $group_field_id = $cmb_group->add_field( array(
    'id'          => $prefix . 'demo',
    'type'        => 'group',
    'description' => esc_html__( 'Generates reusable form entries', 'cmb2' ),
    'options'     => array(
      'group_title'   => esc_html__( 'Product {#}', 'cmb2' ), // {#} gets replaced by row number
      'add_button'    => esc_html__( 'Add Another Product', 'cmb2' ),
      'remove_button' => esc_html__( 'Remove Product', 'cmb2' ),
      'sortable'      => true,
      // 'closed'     => true, // true to have the groups closed by default
    ),
  ) );

  /**
   * Group fields works the same, except ids only need
   * to be unique to the group. Prefix is not needed.
   *
   * The parent field's id needs to be passed as the first argument.
   */
  $cmb_group->add_group_field( $group_field_id, array(
    'name'          => __( 'Product', 'cmb2' ),
    'desc'          => __( 'Field description (optional)', 'cmb2' ),
    'id'            => $prefix . 'asfd',
    'type'          => 'post_ajax_search',
    'query_args'  => array(
      'post_type'     => array( 'product' ),
      'post_status'   => array( 'publish' ),
      'posts_per_page'  => -1
    )
  ) );

  $cmb_group->add_group_field( $group_field_id, array(
    'name'        => esc_html__( 'Description', 'cmb2' ),
    'description' => esc_html__( 'Write a short description for this entry', 'cmb2' ),
    'id'          => 'description',
    'type'        => 'textarea_small',
  ) );

  $cmb_group->add_group_field( $group_field_id, array(
    'name' => esc_html__( 'Entry Image', 'cmb2' ),
    'id'   => 'image',
    'type' => 'file',
  ) );

}

Ajax_term_search vs massive callback lists

First off, many thanks for this tool. It's been huge in my development of a current project.

Question for you about using the fields ajax_search_terms vs creating a custom field type to use an ajaxed powered option_cb to pull in a large options list with 1,100 - 3,000 option's for a select field.

I.e. not using terms, posts, or users...

If I have a 1,100 item list, do you think it's smartest to first insert as terms under a custom taxonomy and then use the ajax_term_search for the field?

Or.....

Or, is it smartest (performance wise) to instead create a custom field type with ajax to pull in the list by itself only when the page with the form is rendered?

If I do that, id have their selected data save to the field meta, while also using a hook to automatically save/insert their selection into the custom taxonomy as a new term (if Not already exists). Thus, I wouldnt always have the 1,100 terms - 3,000 in the db and would populate it only as users select options.

.... but is that pointless because of wp term cache???

Massive issues when putting ajax-populated box in a Repeater field

Whenever creating a group with repeatable fields, I cannot get the the ajax fields to work properly.
I am able to select an option, but when I click on the text, I get an ugly error and the value does not get saved to the database. Has anyone else come across this?
jserror

Activation Error

When I activate the plugin, it launches this error:
The plugin generated 629 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.

Search ajax term not registering in the actual taxonomy

Hello! I have an issues and not sure if it's me:

I have a custom post type name Artworks, and a custom taxonomy named Artists.
I have successfully plugged the ajax search term field and everything is working great at this point.

However, I see that when choosing an artist via the ajax field, it is not registering to the Artists taxonomy - i.e, when I go to the taxonomy term, I see that the artwork is not attached to the artists.

``

$artwork_details->add_field( array(
	'name'          => __( 'Artist', '' ),
	'desc'    		=> 'Start typing a name (You must add the Artist in the Artist section FIRST.)',
	'id'            => 'auction_taxonomy_select',
	'type'          => 'term_ajax_search',
	'multiple'      => false,
	'limit'      	=> -1,
	'query_args'	=> array(
		'taxonomy'		=> 'artists_tax',
		'hide_empty'		=> false
	)


) );

``

On the Artwork page, I also see a sidebar taxonomy menu that allows to have multiple choices, is there a way to disable this?

Thanks a lot for this!

Single post search broken

When 'multiple-item' => true, the search works as advertised. However, when 'multiple-item' => false (which is the default) the search fails. Specifically, a result set is returned, but selecting an option just reveals its post ID and nothing gets saved (see gif).

I can confirm that applying the patches in #17 - specifically commit 9761686 - fixes this, so hopefully that can get merged in soon.

Kapture 2022-07-06 at 18 59 27

Update the jquery autocomplete avoid errors

I was trying this fields but was not working on wordpress 4.8.
I saw that error on console:

devbridgeAutocomplete is not a function

So I updated the library in the package from 1.2.27 to 1.4.1 and now everything is working :-)

Saving as term for the post instead of post_meta

Been using on the frontend and am hoping to use this field type to allow user to set term for a post instead of saving as new post_meta.

Taxonomy -> non-hierachial
Filters --> cmb2_override_meta_value

I could not be using the correct override filters. Do you have an example for overriding the meta save when using this field_type?

Any plans for adding option to set the term(s) on the post instead of saving as post_meta?

Multiple field forget about limit on refresh

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.