Hello,
Using a wysiwyg field, in Group field I receive a Javascript error in console:
"cmb2-conditionals.js?ver=1.0.4:220 Uncaught TypeError: Cannot read property 'replace' of undefined
at CMB2ConditionalsFindDependants (cmb2-conditionals.js?ver=1.0.4:220)"
The first instance of the group has no problems.
But if I create a new instance "Add Another Entry" the error appears.
To solve this problem I modified the file "cmb2-conditionals.js" on line 220.
From:
fieldName = fieldName.replace( /[]$/, '' );
TO:
if ( fieldName ) {
fieldName = fieldName.replace( /[]$/, '' );
}
Is it possible, when you have time, to update the plugin to avoid this error?
Code Cmb2
`/ Hook in and add a metabox to demonstrate repeatable grouped fields /
add_action( 'cmb2_admin_init', 'yourprefix_register_repeatable_group_field_metabox' );
function yourprefix_register_repeatable_group_field_metabox() {
$prefix = 'yourprefixgroup';
/**
* Repeatable Field Groups
*/
$cmb_group = new_cmb2_box( array(
'id' => $prefix . 'metabox',
'title' => esc_html__( 'Repeating Field Group', 'cmb2' ),
'object_types' => array( 'post', 'page' ),
) );
// $group_field_id is the field id string, so in this case: $prefix . 'demo'
$group_field_id = $cmb_group->add_field( array(
'id' => $prefix . 'demo',
'type' => 'group',
'description' => esc_html__( 'Generates reusable form entries', 'cmb2' ),
'options' => array(
'group_title' => esc_html__( 'Entry {#}', 'cmb2' ), // {#} gets replaced by row number
'add_button' => esc_html__( 'Add Another Entry', 'cmb2' ),
'remove_button' => esc_html__( 'Remove Entry', 'cmb2' ),
'sortable' => true, // beta
// 'closed' => true, // true to have the groups closed by default
),
) );
/**
* Group fields works the same, except ids only need
* to be unique to the group. Prefix is not needed.
*
* The parent field's id needs to be passed as the first argument.
*/
$cmb_group->add_group_field( $group_field_id, array(
'name' => esc_html__( 'Entry Title', 'cmb2' ),
'id' => 'title',
'type' => 'text',
// 'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types)
) );
$cmb_group->add_group_field( $group_field_id, array(
'name' => esc_html__( 'Description', 'cmb2' ),
'description' => esc_html__( 'Write a short description for this entry', 'cmb2' ),
'id' => 'description',
'type' => 'textarea_small',
) );
$cmb_group->add_group_field( $group_field_id, array(
'name' => esc_html__( 'Test wysiwyg', 'cmb2' ),
'desc' => esc_html__( 'field description (optional)', 'cmb2' ),
'id' => $prefix . 'wysiwyg',
'type' => 'wysiwyg',
'options' => array( 'teeny' => true, 'wpautop' => false, 'media_buttons' => false, 'textarea_rows' => 10 ),
) );
$cmb_group->add_group_field( $group_field_id, array(
'name' => esc_html__( 'Entry Image', 'cmb2' ),
'id' => 'image',
'type' => 'file',
) );
$cmb_group->add_group_field( $group_field_id, array(
'name' => esc_html__( 'Image Caption', 'cmb2' ),
'id' => 'image_caption',
'type' => 'text',
) );
Sorry, this is an automatic translation.
Clean installation - WP 4.9.1 - Cmb2 2.3.0 - Twentysixteen
Hello, Using a wysiwyg field, in Group field I receive a Javascript error in console: "cmb2-conditionals.js?ver=1.0.4:220 Uncaught TypeError: Cannot read property 'replace' of undefined at CMB2ConditionalsFindDependants (cmb2-conditionals.js?ver=1.0.4:220)"
The first instance of the group has no problems.
But if I create a new instance "Add Another Entry" the error appears.
To solve this problem I modified the file "cmb2-conditionals.js" on line 220. From: fieldName = fieldName.replace( /[]$/, '' ); TO: if ( fieldName ) { fieldName = fieldName.replace( /[]$/, '' ); }
Is it possible, when you have time, to update the plugin to avoid this error?
Code Cmb2 `/ Hook in and add a metabox to demonstrate repeatable grouped fields / add_action( 'cmb2_admin_init', 'yourprefix_register_repeatable_group_field_metabox' ); function yourprefix_register_repeatable_group_field_metabox() { $prefix = 'yourprefixgroup';
}`
Thanks, Claudio_