Conditional logic based on group count

Support MB Conditional Logic Conditional logic based on group count

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #17242
    PascalPascal
    Participant

    I have both "MB Group" and "MB Conditional Logic" installed, they both work as they should.

    But what I now want is make fields appear based on the group 'count', so if a cetain group contains more than 3 items, make field X appear.

    So for example

    'visible' => array(
      'when' => array(
         array( 'meta_box_group', '>', 2 ),
       ),
    )

    Is something like that achievable in any way?

    Thanks in advance!

    #17251
    Anh TranAnh Tran
    Keymaster

    Hi Pascal,

    Did you mean by number of clones? If that, there's no built-in rule to do that. You might want to trigger your own JavaScript action at after_clone hook:

    https://github.com/wpmetabox/meta-box/blob/master/js/clone.js#L157

    #17428
    PascalPascal
    Participant

    Hi Anh,

    Thanks for your suggestion! I was also thinking about a custom callback like explained in the documentation.

    Now I wonder if something like this could work?

    'visible' => array( 'get_clone_count()', '>', 2 )
    
    function get_clone_count(){
      $x = some way to get the 'meta_box_group' clone count
      return $x;
    }

    But then I how do I get data of that from inside that function?

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