CKEditor Widget

What is the CKEditable Widget?

The CKEditable widget allows to you use the amazing WYSIWYG CKEditor plugin on your forms.

Installation

The preferred way to install this extension is through composer.

Either run

composer require 2amigos/yii2-ckeditor-widget:~1.0

or add the following to the require section of your application's composer.json file:

"2amigos/yii2-ckeditor-widget" : "~1.0" 

Usage example

The package comes with two flavors of the widget:

  • CKEditor: For its classic rendering
  • CKEditor Inline: For text elements inline edition

We have also setup three types of presets or toolbarGroup configuration. You can also set your own through its clientOptions attributes. Just make sure you follow the directions as described in the plugin site for its correct configuration and remember, that you have to set them as an array on clientOptions attribute.

CKEditor With 'basic' Preset

use dosamigos\ckeditor\CKEditor;

?>
<?php 
use dosamigos\ckeditor\CKEditor;
?>
<!-- $form is an ActiveForm instance -->
<?= $form->field($model, 'text')->widget(CKEditor::className(), [
    'preset' => 'basic'
]) ?>

CKEditorInline With 'basic' Preset

use dosamigos\ckeditor\CKEditor;

?>
<?php 
use dosamigos\ckeditor\CKEditorInline;
?>
<?php CKEditorInline::begin(['preset' => 'basic']);?>
    This text can be edited now :)
<?php CKEditorInline::end();?>

Share this

Contributors Thanks All

 

Do you have a good idea? Why Don't We Talk?