Choice fields filter not working on clonable field

Support General Choice fields filter not working on clonable fieldResolved

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #15616
    Ryan LauritsenRyan Lauritsen
    Participant

    I cannot get the rwmb_{$field_type}_choice_label or rwmb_{$field_id}_choice_label filters to work on a post field with 'clone' => true:

    https://docs.metabox.io/filters/#choice-fields-user-post-taxonomy-filters

    Could you provide an example of using those filters on a clonable choice field?

    #15617
    Ryan LauritsenRyan Lauritsen
    Participant

    Sorry, correction...

    I cannot get the rwmb_{$field_id}_choice_label filter to work on a post field with 'clone' => true:

    https://docs.metabox.io/filters/#choice-fields-user-post-taxonomy-filters

    Could you provide an example of using this filter on a clonable choice field?

    #15637
    Anh TranAnh Tran
    Keymaster

    Hi Ryan,

    Thanks for your feedback. Let me check that again and will get back to you soon.

    #15638
    Anh TranAnh Tran
    Keymaster

    Hi Ryan,

    I've just done a quick test and it works for me. Here is the code I'm using to register a meta box and filter the label:

    add_filter( 'rwmb_meta_boxes', function( $meta_boxes ) {
        $meta_boxes[] = [
            'title' => 'Cloneable Post Field',
            'fields' => [
                [
                    'id' => 'p',
                    'title' => 'Post',
                    'type' => 'Post',
                    'clone' => true,
                ],
            ],
        ];
        return $meta_boxes;
    } );
    
    add_filter( 'rwmb_p_choice_label', function ( $label, $field, $post ) {
        return "$post->post_type: $post->post_title";
    }, 10, 3 );

    And here is the screenshot:

    https://prnt.sc/opcstu

    #15643
    Ryan LauritsenRyan Lauritsen
    Participant

    Did you try saving and then reloading the page? When I do that only the first field (not the clones) has the filtered label.

    #15667
    Anh TranAnh Tran
    Keymaster

    Oh, I see the problem. After saving, only the 1st input has the filter working. I'll fix it now.

    #15672
    Anh TranAnh Tran
    Keymaster

    Hi Ryan, this bug is fixed in this commit.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.