Skip to content

Remove fails on group field if no TinyMCE present on the page #730

@rogercoathup

Description

@rogercoathup

Issue:

I have a CPT which is just title, excerpt and a CMB metabox containing a repeatable group field.

In this situation, remove doesn't work on group field -- throws a JS error in cmb2.min.js:

Line 382 ReferenceError: Can't find variable: tinyMCE

With a WYSIWYG editor present on the CPT, remove on the group field works as expected.

CMB2 Field Registration Code:

    $args = array(
            'labels' => $labels,
            'public' => true,
            'publicly_queryable' => true,
            'show_ui' => true,
            'query_var' => true,
            'rewrite' => array('slug' => 'slider'),
            'capability_type' => 'post',
            'hierarchical' => false,
            'menu_icon' => 'dashicons-images-alt',
            'has_archive' => true,
            'supports' => array( 'title', 'excerpt', 'thumbnail'),
            'taxonomies' => array()
        );

    register_post_type( 'a21_slider' , $args );

....
    $prefix = '_a21_slider_';

    $slides_box = new_cmb2_box( array(
        'id' => $prefix . 'slides',
        'title' => __( 'Slides', 'a21-slider' ),
        'object_types' => array( 'a21_slider' ),
        'context' => 'normal',
        'priority' => 'default',
        'show_names' => true
      ));

    $slides_group = $slides_box->add_field( array(
        'id'          => $prefix . 'slides',
        'type'        => 'group',
        'description' => __( 'Select your slides', 'a21-slider' ),
        'options'     => array(
            'group_title'   => __( 'Slide {#}', 'a21-slider' ),
            'add_button'    => __( 'Add Another Slide', 'a21-slider' ),
            'remove_button' => __( 'Remove Slide', 'cmb2' ),
            'sortable'      => true,
        ),
    ) );


    $slides_box->add_group_field( $slides_group, array(
            'name' => __( 'Slide', 'a21-slider' ),
            'id'   => $prefix . 'slide',
            'type' => 'file'
        ) );
}

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