Search code examples
javascriptphpyii2ckeditorassets

How do I integrate CKEditor into Yii2 without creating widget?


I looked at widgets 2amigos and MihailDev. They both work fine like this:

echo $form->field($model, 'text')->widget(CKEditor::className(), [
    'options' => ['rows' => 6],
    'preset' => 'basic'
])

but I have to use only CKEditor assets without creating a widget.

CKEditorAsset::register($this);
$activeForm = ActiveForm::begin();
echo $activeForm->field($model, 'text')->textarea();
ActiveForm::end();

Of course this displays a simple textarea field.


Solution

  • echo $activeForm->field($model, 'text')->textarea(['class'=>'ckeditor']);
    

    This displays a text area with CKEditor options. ckeditor help