October CMS resources and help articles

Simple and to the point. Optimized by the community.

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

7
by mjauvin, last modified on August 4th, 2019

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

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

    $widget->secondaryTabs['fields']['content']['type'] = 'richeditor';
});

Discussion

1 comment

0
artistro08
Post on May 11th, 2021 3:00 AM

To use the current editor in OctoberCMS v2.0, specify the backend class

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

            $widget->secondaryTabs['fields']['content']['type'] = 'Backend\FormWidgets\RichEditor';
        });
    }
We use cookies to measure the performance of this website. Do you want to accept these cookies?