Cloned WYSIWYG do not work (no edit/save)

Support General Cloned WYSIWYG do not work (no edit/save)

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #7284
    IdeemafaIdeemafa
    Participant

    Hello people!

    I have a WordPress 4.8.3 installation with Metabox 4.12.4. If I want to clone a WYSIWYG field all the cloned fields are not editable. If I check the code via web developer tool all of them has the same ID. When I save the page all the cloned fields are gone. But if I clone another field, a text field for example, they get different IDs and are saved properly.

    function custom_meta_boxes( $meta_boxes ) {
        $prefix = '';
    
        $meta_boxes[] = array(
            'id' => 'morecontent',
            'title' => esc_html__( 'Weiterer Inhalt', 'theme' ),
            'post_types' => array( 'post', 'page' ),
            'context' => 'advanced',
            'priority' => 'default',
            'autosave' => false,
            'fields' => array(
                array(
                    'id' => $prefix . 'text_1',
                    'type' => 'text',
                    'name' => esc_html__( 'Text', 'theme' ),
                    'clone' => true,
                    'sort_clone' => true,
                ),
                array(
                    'id' => $prefix . 'inhalt_1',
                    'type' => 'wysiwyg',
                    'name' => esc_html__( 'Inhalt', 'theme' ),
                    'clone' => true,
                    'sort_clone' => true,
                ),
            ),
        );
    
        return $meta_boxes;
    }
    add_filter( 'rwmb_meta_boxes', 'custom_meta_boxes' );

    I also checked it in a fresh and new WP installation. Won't work either.

    #7317
    IdeemafaIdeemafa
    Participant

    bump

    Is anyone able to help me figure out, how to solve my problems with cloned fields?

    Thanks!

    #7342
    Anh TranAnh Tran
    Keymaster

    Hi,

    Sorry to miss your topic. I'm checking it. It should have done before as we already targeted this issue.

    #7343
    Anh TranAnh Tran
    Keymaster

    Hi again,

    I've just checked the code and looks like the problem comes from the field ID. For cloning fields, we add suffix "_1", "_2" to the ID of new clones. In this situation, your fields have exactly the same pattern ("inhalt_1") and that breaks the naming of new clones. Please just change the field ID to something else, without the suffix "_x" and it will work.

    PS: I understand that might be something unusual, but we have to have a way to make ID unique.

    #7355
    IdeemafaIdeemafa
    Participant

    Thank you! That solved the problem! 🙂

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Cloned WYSIWYG do not work (no edit/save)’ is closed to new replies.