jcchavezs / cmb2-conditionals

Plugin to relate fields in a CMB2 metabox

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem with repeatable group with 'file' field or 'wysiwyg' field

bjacobs09 opened this issue · comments

I have a repeatable group with many fields. Two of the fields are a 'file' field and a 'wysiwyg' field. All works fine on initial load. But when I click the button to add a new group, the file fields and wysiwyg fields break with the error "Cannot read property 'replace' of undefined".

For the file field, I can see that is is failing on the Add button of that cmb2 field. It can't find the fieldName of the "Add or Upload Files" button.

$cmb->add_group_field( $group_field_id, array( 'name' => 'Module Image 1', 'id' => 'module-image', 'type' => 'file', 'preview_size' => array( 200, 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 Image', // default: "Add or Upload Files" 'remove_image_text' => 'Remove Image', // default: "Remove Image" 'file_text' => 'File', // default: "File:" 'file_download_text' => 'Download', // default: "Download" 'remove_text' => 'Remove', // default: "Remove" ), 'attributes' => array( 'required' => true, // Will be required only if visible. 'data-conditional-id' => wp_json_encode( array( $group_field_id, 'module-image-number' ) ), 'data-conditional-value' => wp_json_encode( array( 'one', 'two' ) ), ), ) );

and

$cmb->add_group_field( $group_field_id, array( 'name' => 'Module Copy', 'id' => 'module-copy', 'type' => 'wysiwyg', ) );

P.S. Sorry can't figure out why it's not picking up my line breaks in the above code.