fsyd88 / yii2-wang-editor
extension of wangEditor for yii2
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- npm-asset/wangeditor: ^3.0
- yiisoft/yii2: >=2.0.6
This package is auto-updated.
Last update: 2025-03-22 21:22:12 UTC
README
Yii2 wangEditor widget
安装
php composer.phar require --prefer-dist fsyd88/yii2-wang-editor "*"
使用
widget 使用:
echo \fsyd88\wangEditor\WangEditorWidget::widget([ 'name' => 'inputName', ]); #或者 echo \fsyd88\wangEditor\WangEditorWidget::widget([ 'model'=>$model, 'attribute'=>'name', ]);
ActiveForm 中使用:
$form = new \yii\widgets\ActiveForm(); echo $form->field($model, 'content')->widget(\fsyd88\wangEditor\WangEditorWidget::className());
文件上传
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 目录
]
]);
更多配置见官网配置