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

#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' );