What is the CKEditable Widget?
The CKEditable widget allows to you use the amazing WYSIWYG CKEditor plugin on your forms.
The preferred way to install this extension is through composer.
composer require 2amigos/yii2-ckeditor-widget:~1.0
or add the following to the require section of your application's
"2amigos/yii2-ckeditor-widget" : "~1.0"
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
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
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();?>