Skip to content

Field type: File_list button unique ID (buggish?) #1345

@pgroot91

Description

@pgroot91

Describe the bug

Not sure if its a bug? But can't seem to figure it out on how to solve the issue. In my project i have multiple file_list but some how the ID and NAME of the buttons come up empty. Warnings in the console that there are no unique IDs for the buttons.

Screenshots

If applicable, add screenshots to help explain your problem.
image

CMB2 Field Registration Code:

add_action( 'cmb2_admin_init', 'amex_media_metabox' );
function amex_media_metabox() {

		/**
		 * Initiate the metabox
		 */
		$amex_media_box_options = array(
			'id'            => 'amex_media_metabox',
			'title'         => __( 'Media', 'cmb2' ),
			'object_types'  => array( 'amex_vehicle', ), // Post type
			'context'       => 'normal',
			'priority'      => 'default',
			'show_names'    => true, // Show field names on the left
			// 'cmb_styles' => false, // false to disable the CMB stylesheet
			// 'closed'     => true, // Keep the metabox closed by default
		);
				
		// Setup meta box
		$cmb = new_cmb2_box( $amex_media_box_options );
		
		$amex_media_tabs = array(
			'config' => $amex_media_box_options,
			'layout' => 'vertical', // Default : horizontal
			'tabs'   => array()
		);
		
		$amex_media_tabs['tabs'][] = array(
			'id'     => 'amex_images_tab',
			'title'  => __( 'Images', 'cmb2' ),
			'fields' => array(
				array(
					'id'      => '_thumbnail', // Saves to WP post thumbnail, allows the_post_thumbnail()
					'name'    => 'Featured Image',
					//'desc'    => 'Upload/Select an image.',
					'type'    => 'file',
					'options' => array(
						'url' => false,
					),
					'text' => array(
						'add_upload_file_text' => 'Add Image'
					),
				), array(
					'name' => 'Gallery',
					'desc' => '',
					'id'   => 'wiki_test_file_list3434',
					'type' => 'file_list',
					// 'preview_size' => array( 100, 100 ), // Default: array( 50, 50 )
					// 'query_args' => array( 'type' => 'image' ), // Only images attachment
					// Optional, override default text strings
					'text' => array(
						'add_upload_files_text' => 'Add Images', // default: "Add or Upload Files"
						'remove_image_text' => 'Remove Image', // default: "Remove Image"
						'file_text' => 'Image:', // default: "File:"
						'file_download_text' => 'Download', // default: "Download"
						'remove_text' => 'Remove', // default: "Remove"
					),
				),
			)
		);
		
		$amex_media_tabs['tabs'][] = array(
			'id'     => 'amex_videos_tab',
			'title'  => __( 'Videos', 'cmb2' ),
			'fields' => array(
				array(
					//'name' => 'Gallery',
					'desc' => '',
					'id'   => 'wiki_test_file_list2',
					'type' => 'file_list',
					// 'preview_size' => array( 100, 100 ), // Default: array( 50, 50 )
					// 'query_args' => array( 'type' => 'image' ), // Only images attachment
					// Optional, override default text strings
					'text' => array(
						'add_upload_files_text' => 'Add Videos', // default: "Add or Upload Files"
						'remove_image_text' => 'Remove Video', // default: "Remove Image"
						'file_text' => 'Video:', // default: "File:"
						'file_download_text' => 'Download', // default: "Download"
						'remove_text' => 'Remove', // default: "Remove"
					),
				),
			)
		);
		
		// set tabs
		$cmb->add_field( array(
			'id'   => '__tabs',
			'type' => 'tabs',
			'tabs' => $amex_media_tabs
		));
		
	}

Your Environment

CMB2 Master

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions