PHP code example of fsyd88 / yii2-wang-editor
1. Go to this page and download the library: Download fsyd88/yii2-wang-editor library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
fsyd88 / yii2-wang-editor example snippets
echo \fsyd88\wangEditor\WangEditorWidget::widget([
'name' => 'inputName',
]);
#或者
echo \fsyd88\wangEditor\WangEditorWidget::widget([
'model'=>$model,
'attribute'=>'name',
]);
$form = new \yii\widgets\ActiveForm();
echo $form->field($model, 'content')->widget(\fsyd88\wangEditor\WangEditorWidget::className());
php composer.phar
echo \fsyd88\wangEditor\WangEditorWidget::widget([
'model'=>$model,
'attribute'=>'name'
]);
#控制器中加上
public function actions() {
return [
'upload' => [
'class' => 'fsyd88\wangEditor\WangEditorAction',
]
];
}
echo \fsyd88\wangEditor\WangEditorWidget::widget([
'model'=>$model,
'attribute'=>'name',
'id'=>'iidd', #id for div(container);div 容器id
'options'=>['id'=>'inputId'], #hidden input options; 隐藏input的选项
'customConfig'=>[ #editor custom config info ;编辑器配置项
'menus'=>[''head','bold','italic'],
'uploadImgServer'=>'upload' #upload ;上传图片 默认使用 web/uploads 目录
]
]);