Custom Fields
Re-Envisioned
Support General Choice fields filter not working on clonable field

This topic contains 6 replies, has 2 voices, and was last updated by  Anh Tran 1 week, 5 days ago.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Author
    Replies
  • #15617

    Ryan 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 Tran
    Keymaster

    Hi Ryan,

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

    #15638

    Anh 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 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 Tran
    Keymaster

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

    #15672

    Anh Tran
    Keymaster

    Hi Ryan, this bug is fixed in this commit.

Viewing 6 replies - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.