Custom Fields
Re-Envisioned
Support Meta Box Conditional Logic Conditional logic does not work based on a taxonomy field

This topic contains 3 replies, has 2 voices, and was last updated by  Hansjakob Fehr 2 months, 2 weeks ago.

  • Creator
    Topic
  • #12367

    Hansjakob Fehr
    Participant

    Hello.
    I’d like to show/hide a meta box with conditional logic, based on a taxonomy_advanced-field, but it does not work.
    I dried it with a radio button and there it works fine.
    Thank you for your help.
    Best regards
    Jacob

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #12370

    Hansjakob Fehr
    Participant

    It works also when i use post_category … but just when i use it in the category meta box.
    Post_category with taxonomy field does not work.

    I dried it different ways:
    //array( ‘slug:post_category’, ‘in’, array( ‘buch’ ) ),
    //array( ‘slug:tax_input[medium]‘, ‘in’, array( ‘buch’ )),
    //array( ‘slug:tax_input[medium]‘, ‘=’, ‘buch’ ),
    //array( ‘medium’, ‘in’, array( ‘buch’ )),
    //array (‘medium’,’=’,’buch’, ),

    What do i wrong?
    Thanks again.
    Jacob

    #12389

    Anh Tran
    Keymaster

    Hi Jacob,

    I think array( 'medium', 'in', array( 'buch' )) should work for taxonomy_advanced. Would you mind posting the code of meta box here for testing?

    #12392

    Hansjakob Fehr
    Participant

    Hi Anh
    Thank you for your helping hand.
    Here comes my code.
    Thank you.
    best regards
    Jacob

    function Buch( $meta_boxes ) {
        $meta_boxes[] = array(
            'title' => 'Buch',
            'context' => 'advanced',
            'autosave' => true,
            'visible' => array (
                'when' => array (
                //array( 'slug:post_category', 'in', array( 'buch' ) ),
                //array( 'slug:tax_input[medium]', 'in', array( 'buch' )),
                //array( 'slug:tax_input[medium]', '=', 'buch' ),
                //array ('medium','=','buch', ),
                array( 'medium', 'in', array( 'buch' )),
                //array ('levelSerie','=','mainS', ),
                ),
                'relation' => 'and',
              ),
                
            'fields' => array(
    
                array(
                'id' => 'format',
                'type' => 'text',
                'name' =>  'Format',
                'columns' => 3,
                
                ),
                array(
                'id' => 'umfang',
                'type' => 'text',
                'name' =>  'Umfang',
                'columns' => 3,
                
                ),
                array(
                'id' => 'verlag',
                'type' => 'text',
                'name' =>  'Verlag',
                'columns' => 3,
                
                ),
                array(
                'id' => 'herausgeber',
                'type' => 'text',
                'name' =>  'Herausgeber',
                'columns' => 3,
                
                ),
    ),
     );
        return $meta_boxes;
    }
    add_filter( 'rwmb_meta_boxes', 'Buch' );
            
            
    
    function Projekt( $meta_boxes ) {
        $meta_boxes[] = array(
            'title' => 'Projekt',
            'context' => 'advanced',
            'autosave' => true,
            'fields' => array(
                array(
                'name' => 'Datum',
                'id' => 'datumProjekt',
                'type' => 'date',
                'columns' => 3,
                ),
                array(
                'name' => 'Medium',
                'id' => 'medium',
                'type' => 'taxonomy_advanced',
                'taxonomy' => 'medium',
                'field_type' => 'select_advanced',
                'columns' => 3,
                'hidden' => array( 'levelSerie', '=', 'subS' ),
                ),
                array(
                'name' => 'Status',
                'id' => 'status',
                'type' => 'taxonomy_advanced',
                'taxonomy' => 'status',
                'multiple' => false,
                'columns' => 3,
                'hidden' => array( 'levelSerie', '=', 'subS' ),
                ),
            
                array(
                    'id' => 'divider_4',
                    'type' => 'divider',
                    'name' => ( 'Divider' ),
                ),
                array(
                'name'    => 'Level Gruppe',
                'id'      => 'levelGruppe',
                'type'    => 'radio',
                'std' => 'mainG',
                'inline'=> false,
                'options' => array(
                'mainG'=> 'Main',
                'subG' => 'Sub',
                ),
                'columns' => 3,
                ),
                array(
                'name' => 'Link Gruppe',
                'id' => 'linkGruppe',
                'type' => 'post',
                'taxonomy' => 'post',
                'query_args' => array(
                    'meta_query' => array(
                                        array(
                                        'relation' => 'AND',
                                        array(
                                        'value' => 'mainG',
                                        'compare' => '=',
                                        ),
                                        array(
                                        'value' => 'mainS',
                                        'compare' => '=',
                                        ),
                                    ),
                            ),
                    ),
                'multiple' => false,
                'columns' => 3,
                'hidden' => array( 'levelGruppe', '=', 'mainG' ),
                ),
                
                array(
                'name'    => 'Level Serie',
                'id'      => 'levelSerie',
                'type'    => 'radio',
                'std' => 'mainS',
                'inline'=> false,
                'options' => array(
                'mainS'=> 'Main',
                'subS' => 'Sub',
                ),
                'columns' => 3,
                ),
            
                array(
                'name' => 'Link Serie',
                'id' => 'linkSerie',
                'type' => 'post',
                'taxonomy' => 'post',
                'query_args' => array(
                    'meta_value' => 'mainS'
                ),
                'multiple' => false,
                'columns' => 3,
                'hidden' => array( 'levelSerie', '=', 'mainS' ),
                ),
                
            
            
                array(
                    'id' => 'divider_4',
                    'type' => 'divider',
                    'name' => ( 'Divider' ),
                ),
                array(
                    'id' => 'bereichAufwand',
                    'type' => 'group',
                    'clone'  => true,
                    'sort_clone' => true,
                    'add_button' => ( '+'),
                    'fields' => array(
                    
                        array(
                            'name' => 'Bereich',
                            'id' => 'bereich',
                            'type' => 'taxonomy_advanced',
                            'taxonomy' => 'bereich',
                            'field_type' => 'select_advanced',
                            'columns' => 3,
                        ),
                        array(
                            'name' => 'Aufwand in h',
                            'id' => 'aufwand',
                            'type' => 'number',
                            //'desc' => ( 'Ungefährer Aufwand in Stunden.'),
                            'columns' => 2,
                        ),
                    array(
                    'id' => 'divider_4',
                    'type' => 'divider',
                    'name' => ( 'Divider' ),
                        ),
                    array(
                        'id' => 'bilder',
                        'type' => 'image_advanced',
                        'name' => ( 'Bilder'),
                        'image_size' => 'medium',
                        'columns' => 12,
                ),
                    ),
                ),
            ),
        );
        return $meta_boxes;
    }
    add_filter( 'rwmb_meta_boxes', 'Projekt' );
Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.