Custom Fields
Re-Envisioned
Support Meta Box Conditional Logic Conditional logic based on group count

  • Creator
    Topic
  • #17242
    Pascal
    Participant

    I have both “Meta Box Group” and “Meta Box 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!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
    Replies
  • #17251
    Anh 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
    Pascal
    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 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.