Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

options page fields within repeatable groups display array() if empty fields are saved #332

Closed
ahm-3d opened this issue May 25, 2015 · 2 comments

Comments

@ahm-3d
Copy link

ahm-3d commented May 25, 2015

custom options page fields within repeatable groups display array() if empty fields are saved.
the custom options page is calling the function below:

function theme_options_metabox($metabox_id, $key) {

    $prefix = 'theme';
    $cmb_options = new_cmb2_box( array(
        'id'      => $metabox_id,
        'title'   => 'Theme Options',
        'hookup'  => false,
        'show_on' => array(
            'key'   => 'options-page',
            'value' => array( $key )
        )
    ) );

    $group_field_id = $cmb_options->add_field( array(
        'id'          => $prefix . 'demo',
        'type'        => 'group',
        'description' => __( 'Generates reusable form entries', 'cmb2' ),
        'options'     => array(
            'group_title'   => __( 'Entry {#}', 'cmb2' ),
            'add_button'    => __( 'Add Another Entry', 'cmb2' ),
            'remove_button' => __( 'Remove Entry', 'cmb2' ),
            'sortable'      => true,
        ),
    ) );

    $cmb_options->add_group_field( $group_field_id, array(
        'name'       => __( 'Entry Title', 'cmb2' ),
        'id'         => 'title',
        'type'       => 'text',
    ) );
}

wordpress version: 4.2.2
CMB2 version: 2.0.6

@johnsonpaul1014
Copy link
Contributor

This bug is caused by a call to array_filter in CMB2.php (line 596 in the current code base). I have commented it out for now, but this was obviously put in for a reason, and I'm hoping the CMB2 folks can answer why or if it is still needed.

@jtsternberg
Copy link
Member

Please don't ever edit CMB2 core, for some of the same reasons you would not edit WordPress core. If you modify something to 'fix' it for yourself, there is no guarantee that you are not then breaking it for somebody else who is using the library. CMB2 only ever loads one instance of itself, so if your (edited) version is the one that gets loaded, all other plugins/themes/etc depending on CMB2 will now be using your (edited) version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants