Okay
  Public Ticket #2180205
tinymce on frontend submission form
Closed

Comments

  • senzoi started the conversation

    Hello,

    i try to configure tinymce for the front end submission form.

    i try the code saw in an other article but don't work fine: 

    $elements['description'] = wp_editor('','stec-builder-element-content-textarea-style', array( 'textarea_name' => 'description' ));

    Could you help me please?

  • senzoi replied

    i want to use it for Description textarea.

  •  894
    Zhivko replied

    Try with output buffer:

    add_filter('stec_builder_front_elements', function($elements) {
        ob_start();
        wp_editor('', 'stec-builder-element-content-textarea-style', array('textarea_name' => 'description'));
        $editor = ob_get_clean();     $elements['description'] = array(
            $editor
        );
        return $elements;
    });

    Stachethemes Developer

  • senzoi replied

    Hi Zhivko,

    thank you for your answer, but now i see only visual text and a white windows withou any buttons?

  •  894
    Zhivko replied

    Try the wp editor js api instead.

    Example:

    add_filter('stec_builder_front_elements', function($elements) {
        $elements['description'] = array(
            '<div class="stec-wp-editor-container"></div>' // editor placeholder
        );
        return $elements;
    }); add_action('stec_after_html', function() {
        // Load editor api js
        wp_enqueue_editor();
        ?>
        <script type="text/javascript">
            (function ($) {
                $.stecExtend(function (m) {
                    m.$instance.on('click', '.stec-event-create-form', function () {
                        if (!$(this).hasClass('active')) {
                            var editorContainer = m.glob.options.id + ' .stec-wp-editor-container';
                            wp.editor.initialize(editorContainer);
                        }
                    });
                });
            })(window.jQuery);
        </script>
        <?php
    });

    Stachethemes Developer