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

issues with repeatable fields in a group and with sorting the groups #712

Open
manmar opened this issue Aug 17, 2016 · 7 comments
Open

issues with repeatable fields in a group and with sorting the groups #712

manmar opened this issue Aug 17, 2016 · 7 comments
Labels

Comments

@manmar
Copy link

manmar commented Aug 17, 2016

I was using CMB2 v2.1.2 with WP v4.5.3 and had an issue with text repeatable fields within a group when sorting - the number of the repeatable fields would not move up or down when clicking on arrows. For example if the first item had 2 repeatable text fields and the second item had 3 text fields, after changing the order the second (now first) item would have only 2 text fields and the first would have 3 fields (one empty).
I've made a video to show what was going on exactly: http://recordit.co/COtIqkm5Mf

Then I updated to v2.2.2.1 (also tried 2.2.3.beta) and the same issue is still there but there is also a new one. Upon updating the page, two more groups are added. Next to last group will get the last repeating field value, and the last one will be empty.
Again, here is a video demonstrating the issue: http://recordit.co/Z8VgHU80hT

@tw2113
Copy link
Contributor

tw2113 commented Aug 17, 2016

Can you provide your metabox configuration for this please?

It'd be everything with $something = new cmb2_meta_box() and the $something->add_field() bits.

Wanting to see if I can recreate the issue.

@manmar
Copy link
Author

manmar commented Aug 19, 2016

Sorry for the wait, here is the configuration:

add_action( 'cmb2_admin_init', 'mm_newsletter_archive' );

function mm_newsletter_archive() {

    $prefix = '_nla_';

    $nla = new_cmb2_box( array(
        'id' => $prefix . 'pdf',
        'title' => __( 'Newsletter Archive', 'cmb2' ),
        'object_types' => array( 'page' ),
        'context' => 'normal',
        'priority' => 'high',
        'show_on' => array( 'key' => 'page-template', 'value' => 'page-newsletter-archive.php' ),
    ) );


    $nla_group = $nla->add_field( array(
        'id' => $prefix . 'group',
        'type' => 'group',
        'description' => __( 'Create a list of newsletters', 'cmb2' ),
        'options' => array(
            'group_title' => __( 'Newsletter {#}', 'cmb2' ),
            'add_button' => __( 'Add Another Newsleter', 'cmb2' ),
            'remove_button' => __( 'Remove Newsletter', 'cmb2' ),
            'sortable' => true,
        ),
    ) );


    $nla->add_group_field( $nla_group, array(
        'name' => __( 'Newsletter Title', 'cmb2' ),
        'id' => 'title',
        'type' => 'text',
    ) );


    $nla->add_group_field( $nla_group, array(
        'name' => __( 'Newsletter URL', 'cmb2' ),
        'desc' => __( 'Upload a file or enter an URL.', 'cmb2' ),
        'id' => 'file',
        'type' => 'file',
        'preview_size' => array( 100, 100 ),
    ) );


    $nla->add_group_field( $nla_group, array(
        'name' => __( 'Newsletter Contents', 'cmb2' ),
        'id' => 'contents',
        'type' => 'text',
        'repeatable' => true, 
    ) );

}

@tw2113
Copy link
Contributor

tw2113 commented Aug 23, 2016

Haven't forgotten this one.

@tw2113
Copy link
Contributor

tw2113 commented Aug 28, 2016

@jtsternberg as far as I can tell, this is a legitimate issue going on. The fields "disappear" as you move them up, but they also come back as you move them back down.

Also seeing these errors show up in the console.

screen shot 2016-08-28 at 1 06 05 am

@tw2113 tw2113 added the bug label Sep 1, 2016
@alvarogois
Copy link

I'm having the same issues. A new empty group is created upon saving the post. If I delete the empty group and hit save again, the empty group is in fact deleted.

As to the sortable group, same error: if the number of repeatable fields is different inside each group, the number of fields stays fixed despite sorting the content, just as @manmar described. So, if the first group has 2 fields and the second has 3 fields, when sorting only the first 2 fields of the second group are shown in their new position as first group fields. Also, if I add another line/field to this group, the content of the missing field is automatically inserted in this new created field.

@RubenMartins
Copy link
Contributor

Any updates on this?

@tw2113
Copy link
Contributor

tw2113 commented Dec 14, 2016

Nothing I've seen or heard of.

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

No branches or pull requests

4 participants