cmb2-field-post-search-ajax icon indicating copy to clipboard operation
cmb2-field-post-search-ajax copied to clipboard

Limit => -1 appears to be ignored

Open jonathanstegall opened this issue 6 years ago • 1 comments

I have a field that should theoretically allow unlimited posts to be attached to it, but I think adding -1 as the limit attribute gets ignored.

Here's an example when I put a limit of 50.

Code:

$newsletter_top_posts->add_field(
    array(
        'name'       => __( 'Top Stories' ),
        'desc'       => __( 'Search for a post here', ),
        'id'         => 'top_posts',
        'type'       => 'post_search_ajax',
        'sortable'   => true,
        'limit'      => 50,
        'query_args' => array(
            'orderby'    => 'modified',
            'order'      => 'DESC',
            'date_query' => array(
                array(
                    'column' => 'post_modified',
                    'after'  => 2018-07-23 11:45:25,
                ),
            ),
        ),
    )
);

Screenshot:

image

Code when I use -1 instead:

$newsletter_top_posts->add_field(
    array(
        'name'       => __( 'Top Stories' ),
        'desc'       => __( 'Search for a post here', ),
        'id'         => 'top_posts',
        'type'       => 'post_search_ajax',
        'sortable'   => true,
        'limit'      => -1,
        'query_args' => array(
            'orderby'    => 'modified',
            'order'      => 'DESC',
            'date_query' => array(
                array(
                    'column' => 'post_modified',
                    'after'  => 2018-07-23 11:45:25,
                ),
            ),
        ),
    )
);

Screenshot:

image

So it uses the first item and then doesn't let me add any additional ones. Is this a bug, or am I missing how this ought to work?

jonathanstegall avatar Jul 25 '18 16:07 jonathanstegall

Just noticed this issue, would be great to get this merged!

scottsawyer avatar Nov 26 '20 08:11 scottsawyer