CKEditor and KCFinder
The preferred way to install this extension is through composer.
Either run
composer require firdows/yii2-mkeditor "*"
or add
"firdows/yii2-mkeditor": "*"
to the require section of your composer.json
file.
Once the extension is installed, simply use it in your code by :
Convert textarea to CKEditor
<?php
//CKEditor
echo $form->field($model, 'detail')->widget(
\firdows\mkeditor\CKEditor::className(),
[
'uploadDir' => '/var/www/public_html/UserFiles',
'uploadURL' => '/UserFiles/',
'filemanager'=>true, //true = enabled kcfinder, false = disabled kcfinder
'preset'=>'full' //toolbar -> basic, standard, full
]
)->label(false); ?>
Example
<?php $this->registerJs("
var content = '';
CKEDITOR.on('instanceCreated', function (e) {
content = e.editor.getData();
e.editor.on('change', function (ev) {
content = ev.editor.getData();
});
});
"); ?>
<?php
//CKEditor
echo $form->field($model, 'detail')->widget(
\firdows\mkeditor\CKEditor::className(),
[
'uploadDir' => '/var/www/public_html/UserFiles',
'uploadURL' => '/UserFiles/',
'filemanager'=>true, //true = enabled kcfinder, false = disabled kcfinder
'preset'=>'full', //toolbar -> basic, standard, full
'onChange' => true
]
)->label(false); ?>
Example
Comments