Winter CMS resources and help articles

Simple and to the point. Optimized by the community.

Use a rich editor form widget as the Winter.Blog post editor

2
by mjauvin, last modified on May 23rd, 2023

Use the following Event listener to force the Winter.Blog plugin to always use a richeditor form widget.

Event::listen('backend.form.extendFields', function($widget) {
        // Extend only the Blog\Posts controller & Extend only Blog\Post model
        if (!($widget->getController() instanceof \Winter\Blog\Controllers\Posts
                && $widget->model instanceof \Winter\Blog\Models\Post)
        ){  
                return;
        }

        $field = $widget->getField('content');
        if (class_exists('Winter\Translate\FormWidgets\MLRichEditor')) {
                $field->config['widget'] = 'Winter\Translate\FormWidgets\MLRichEditor';
        } else {
                $field->config['widget'] = 'Backend\FormWidgets\RichEditor';
        }
});

Discussion

1 comment

0
sribatsa
Post on July 3rd, 2022 10:14 AM

It worked like magic!!! ***** Searching for the solution from the very first day...

We use cookies to measure the performance of this website. Do you want to accept these cookies?