Yii2如何在CKEditor中添加代码片段?

时间:2015-08-04 10:21:57

标签: php ckeditor yii2

我从这里下载了CKEditor https://github.com/2amigos/yii2-ckeditor-widget 现在我想整合代码段http://docs.ckeditor.com/#!/guide/dev_codesnippet

Mayby有人可以解释一下如何逐步完成这项工作吗?我通过composer下载了ckeditor后添加了

 echo $form->field($model, 'instruction')->textarea()
->widget(CKEditor::className(), [
        'options' => ['rows' => 6],
        'preset' => 'full'
    ]); 

我现在如何整合代码段?

2 个答案:

答案 0 :(得分:1)

Composer软件包安装在应用程序根目录的vendor目录中。我打赌它会像vendor/dosamigos/ckeditor。您应该找到plugins文件夹,您可以在其中相应地安装CKEditor文档的代码段。然后当你在Yii2代码中使用它时,写下类似于:

的东西
<?= $form->field($model, 'field_name')->widget(CKEditor::className(), [
    'options' => ['rows' => 10],
    'preset' => 'full', 
    'clientOptions' => ['extraPlugins' => 'codesnippet']
]) ?>

答案 1 :(得分:-2)

您只需在表单文件中添加以下代码:

<?= $form->field($model, 'field_name')->widget(CKEditor::className(), [
        'options' => ['rows' => 10],
        'preset' => 'full', 
    ]) ?>
相关问题