Custom Fields
Re-Envisioned
Support Meta Box Conditional Logic Custom callback not working

  • Creator
    Topic
  • #24939
    Julien
    Participant

    Hello,

    I tried today to make working my custom callback condition but it's not working...
    I followed documentation without success

    Example code

    <?php
    add_action( 'admin_head', function(){
      ?>
          <script type="text/javascript">
              function dummy_function(){
                console.log('dummy');
                return false;
              }
          </script>
    <?php
    }, 100);
    
    add_filter( 'rwmb_meta_boxes', function($meta_boxes){
    
      $meta_boxes[] = array(
        'title'  => 'Conditional meta',
        'post_types' => array( 'post', 'page' ),
        'fields' => array(
          array(
            'visible' => ['dummy_function()', true],
            'name'       => 'Color',
            'id'    => "color",
            'type'       => 'text',
          ),
        ),
      );
    
      return $meta_boxes;
    
    });
    ?>

    If I comment lines 249 on conditional-logic.js my function is evaluated.
    File is located on /plugins/meta-box-aio/meta-box-conditional-logic/conditional-logic.js

    All is updated
    Wordpress 5.7
    Meta Box 5.3.9
    Meta Box AIO 1.13.4

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
    Replies
  • #24940
    Julien
    Participant
    <?php
    if ( ! isGutenbergElement( logic[0] ) && ! dependentFieldSelector && !compare(logic[0], ')', 'contains') ) {
        return;
    }

    instead of

    <?php
    if ( ! isGutenbergElement( logic[0] ) && ! dependentFieldSelector ) {
        return;
    }

    It could be a real fix ?

    #24946
    Long Nguyen
    Moderator

    Hi,

    Thank you for your effort.

    Your suggestion code works as well on my end. I will inform the development team to check on this case.

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