fix
This commit is contained in:
parent
267047211d
commit
12bee95561
|
@ -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 )
|
// 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() ) );
|
$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 ) {
|
if( $field->args( 'multiple' ) == true ) {
|
||||||
$default_limit = -1; // 0 or -1 means unlimited
|
$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
|
?><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( isset( $value ) && ! empty( $value ) ){
|
||||||
|
|
||||||
if( ! is_array( $value ) && strpos( $value, ', ' ) ) {
|
|
||||||
$value = explode(', ', $value);
|
|
||||||
}
|
|
||||||
if( ! is_array( $value ) ) {
|
if( ! is_array( $value ) ) {
|
||||||
$value = array( $value );
|
$value = array( $value );
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
$('.cmb-ajax-search:not([data-ajax-search="true"])').each(function () {
|
$('.cmb-ajax-search:not([data-ajax-search="true"])').each(function () {
|
||||||
$(this).attr('data-ajax-search', true);
|
$(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 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 object_type = $(this).attr('data-object-type');
|
||||||
var query_args = $(this).attr('data-query-args');
|
var query_args = $(this).attr('data-query-args');
|
||||||
|
@ -76,7 +75,7 @@
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Singular
|
// Singular
|
||||||
$('input[name=' + field_name + ']').val( suggestion.id ).change();
|
$('input[name="' + field_name + '"]').val( suggestion.id ).change();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue