alexis-magina / cmb2-field-post-search-ajax

CMB2 field type to attach posts to each others.
GNU General Public License v3.0
40 stars 18 forks source link

Limit => -1 appears to be ignored #22

Open jonathanstegall opened 6 years ago

jonathanstegall commented 6 years ago

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?

scottsawyer commented 3 years ago

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