• Hassine RIANI

    (@rianihossine)


    cmb2 MULTICHECK option does not show values on the table of admin , when i modified the select option of CMB2 fields to multicheck the values does not count and show properly to admin dashboard of my new constructeur page details .I ‘m looking to show all the values retrieved from the :
    $makes_array = array(” => esc_html__( ‘- constructeur -‘, ‘enovathemes-addons’ ));
    $models_array = array(” => esc_html__( ‘- Type de vehicule -‘, ‘enovathemes-addons’ ));

    the entire code of the function and the metabox is the below :

    add_action( 'cmb2_admin_init', 'enovathemes_addons_register_taxonomy_metabox' );
     function enovathemes_addons_register_taxonomy_metabox() {
     	$prefix = 'enovathemes_addons_';
     	$makes_array = array('' => esc_html__( '- constructeur -', 'enovathemes-addons' ));
    	$models_array = array('' => esc_html__( '- Type de vehicule -', 'enovathemes-addons' ));
    	$term_args_model = array(
    
    		'taxonomy' => 'product-model',
    		
    		'hide_empty' => false,
    		
    	
    		
    		);
    		
    	$models = get_terms($term_args_model);
       if ($models) {
    	   foreach ($models as $term) {
    		   $models_array[$term->term_id] = $term->name;
    	   }
    	   
       }
       $term_args_makes = array(
    
    	'taxonomy' => 'product-make',
    	
    	'hide_empty' => false,
    	
    	
    	);
    	
    
    	// $makes = get_terms($term_args_makes);
    	$makes = get_terms($term_args_makes);
    
     	
    
        if ($makes) {
        	foreach ($makes as $term) {
    	    	$makes_array[$term->term_id] = $term->name;
    		}
    		
    	}
    	
    	
        /*  Models
    	/*-------------------*/
    
    		$cmb_term_model = new_cmb2_box( array(
    			'id'               => $prefix . 'model',
    			'title'            => esc_html__( 'Model metabox', 'enovathemes-addons' ),
    			'object_types'     => array( 'term' ),
    			'taxonomies'       => array( 'product-model'),
    		));
    
    		$cmb_term_model->add_field( array(
    			'name'    => esc_html__( 'Choisir constructeur', 'enovathemes-addons' ),
    			'id'      => $prefix . 'make',
    			'type'    => 'multicheck',
    			'classes' => 'cmb-type-multicheck',
    			'select_all_button' => false,
    			// 'options' => $makes_array,
    			'options' => $makes_array,
    				
    			
    			'default' => '',
    		));
    
    		$cmb_term_trim = new_cmb2_box( array(
    			'id'               => $prefix . 'trim',
    			'title'            => esc_html__( 'Trim metabox', 'enovathemes-addons' ),
    			'object_types'     => array( 'term' ),
    			'taxonomies'       => array('product-trim'),
    		));
    
    		$cmb_term_trim->add_field( array(
    			'name'    => esc_html__( 'Choisir constructeur', 'enovathemes-addons' ),
    			'id'      => $prefix . 'make',
    			'type'    => 'multicheck',
    			// 'classes' => 'select-230',
    			'classes' => 'cmb-type-multicheck',
    			'select_all_button' => false,
    			 'options' => $makes_array,
    			
    			
    			
    			'default' => '',
    		));
    
    		$cmb_term_trim->add_field( array(
    			'name'    => esc_html__( 'Choisir type de vehicule', 'enovathemes-addons' ),
    			'id'      => $prefix . 'model',
    			'type'    => 'multicheck',
    			'classes' => 'cmb-type-multicheck',
    			'select_all_button' => false,
    			 'options' => $models_array,
    			 
    			
    			'default' => '',
    		));
    
    		$cmb_term_trim->add_field( array(
    			'name'    => esc_html__( 'Entrer année', 'enovathemes-addons' ),
    			'desc'  => esc_html__( 'Entrez une valeur entière ou utilisez un tiret pour la période (1975-2001), ou juste des années séparées par des virgules (2001,2002,2003)', 'enovathemes-addons' ),
    			'id'      => $prefix . 'year',
    			'type'    => 'text_medium',
    			'default' => '',
    		));
    
    	}
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘cmb2 MULTICHECK option does not show values on the table of admin’ is closed to new replies.