This commit is contained in:
Daniele Scasciafratte 2019-03-27 19:37:30 +01:00
parent 267047211d
commit 12bee95561
2 changed files with 5 additions and 6 deletions

View File

@ -68,16 +68,16 @@ if( ! class_exists( 'CMB2_Field_Ajax_Search' ) ) {
// Current filter is cmb2_render_{$object_to_search}_ajax_search ( post, user or term )
$object_to_search = str_replace( 'cmb2_render_', '', str_replace( '_ajax_search', '', current_filter() ) );
if( ! is_array( $value ) && strpos( $value, ', ' ) ) {
$value = explode(', ', $value);
}
if( $field->args( 'multiple' ) == true ) {
$default_limit = -1; // 0 or -1 means unlimited
?><ul id="<?php echo $field_name; ?>_results" class="cmb-ajax-search-results cmb-<?php echo $object_to_search; ?>-ajax-search-results"><?php
if( isset( $value ) && ! empty( $value ) ){
if( ! is_array( $value ) && strpos( $value, ', ' ) ) {
$value = explode(', ', $value);
}
if( ! is_array( $value ) ) {
$value = array( $value );
}

View File

@ -3,7 +3,6 @@
$('.cmb-ajax-search:not([data-ajax-search="true"])').each(function () {
$(this).attr('data-ajax-search', true);
var input_id = $(this).attr('id'); // Field id with '_input' sufix (the searchable field)
var field_id = $(this).attr('id').replace( new RegExp('_input$'), '' ).replace(/[\[\]']+/g, '_'); // Field id, the true one field
var object_type = $(this).attr('data-object-type');
var query_args = $(this).attr('data-query-args');
@ -76,7 +75,7 @@
}
} else {
// Singular
$('input[name=' + field_name + ']').val( suggestion.id ).change();
$('input[name="' + field_name + '"]').val( suggestion.id ).change();
}
}
},