Log1x/acf-move-wp-editor

editor functions broke in repeater or flexible content field

Closed this issue · 4 comments

I just notice that the plugin doesn't work when used inside a flexible content !

All editor options (bold, italic,....) are hidden except for the "add medias button". (add medias button is still functional probably because not inside the same div as basics options)
And switch between visual editor or brut text is not possible anymore.

From what I can observe it could be link to issues regarding using "append" with elements that already use jquery trigger. (If not set with "live" or "on")

capture d ecran 2018-02-12 a 17 40 08

Log1x commented

It shouldn't be used inside of flexible content. It's only meant to be used once, and is simply moving the content editor for your page or post to say an accordion or a tab for better back-end styling.

Totally agree with you on the logic for the repeater field.

But I use flexible content only to let admin chose 1 layout among severals. Each layout having specific fields.
In this case it should make sense to be able to use WP editor.

Log1x commented

For that, I'd recommend hiding the default editor and then perhaps hooking save_post to add your content from a custom field.

Example:

add_action('acf/save_post', function ($post_id) {
    $content = get_field('content_example', $post_id);
    if (!empty($content)) {
        wp_update_post([
            'ID' => $post_id,
            'post_content' => $content
        ]);
    }
});

Thanks for the feedback.
That will do the trick for me :)