CMB2-Snippet-Library
CMB2-Snippet-Library copied to clipboard
"Notice: Array to string conversion" of multicheck field in own field type
trafficstars
I followed this example: https://github.com/WebDevStudios/CMB2/wiki/Adding-your-own-field-types#example-4-multiple-inputs-one-field-lets-create-an-address-field
Everything works fine until I change type of 'state' field from select to multicheck.
Expected Behavior:
Change select dropdown to multicheck checkboxes.
Actual Behavior:
It throws Notice: Array to string conversion in .../wp-content/plugins/cmb2/includes/types/CMB2_Type_Base.php on line 103
Steps to reproduce (I have confirmed I can reproduce this issue on the trunk branch):
Create custom field type address using this snippet:
https://github.com/WebDevStudios/CMB2-Snippet-Library/blob/master/custom-field-types/address-field-type.php
and change select to multicheck on line 134.
CMB2 Field Registration Code:
add_action( 'cmb2_admin_init', 'yourprefix_register_demo_metabox' );
function yourprefix_register_demo_metabox() {
$cmb = new_cmb2_box( array(
// Box Config...
) );
$cmb->add_field( array(
// Field Config...
'type' => 'address'
) );
}
Thank you for any help.
Reference: https://github.com/CMB2/CMB2/issues/801