Jodit widget for Yii2 </a>
The preferred way to install this extension is through composer.
Either run
Copyphp composer.phar require --prefer-dist jodit/yii2-jodit "*"
or
Copycomposer require --prefer-dist jodit/yii2-jodit
or add
Copy"jodit/yii2-jodit": "*"
to the require section of your composer.json
file.
Add to config file (config/web.php or common\config\main.php)
Copy'modules' => [ 'jodit' => 'yii2jodit\JoditModule', ],
or if you want to change the upload directory. to path/to/uploadfolder default value @webroot/uploads
Copy'modules' => [ 'jodit' => [ 'class' => 'yii2jodit\JoditModule', 'extensions'=>['jpg','png','gif'], 'root'=> '@webroot/uploads/', 'baseurl'=> '@web/uploads/', 'maxFileSize'=> '20mb', 'defaultPermission'=> 0775, ], ],
note: You need to create uploads folder and chmod and set security for folder upload reference:Protect Your Uploads Folder with
.htaccess
, []How to Setup Secure Media Uploads](http://digwp.com/2012/09/secure-media-uploads/)
Once the extension is installed, simply use it in your code by :
Copyecho $form->field($model, 'content')->widget(\yii2jodit\JoditWidget::className(), [ 'settings' => [ 'buttons'=>[ 'bold', 'italic', 'underline', '|', 'ul', 'ol', '|', 'image', '|', 'hr', ], ], ]);;
or not use ActiveField
Copyecho \yii2jodit\JoditWidget::widget([ 'model' => $model, 'attribute' => 'content' ]);
editors config:
Copyecho $form->field($model, 'content')->widget(\yii2jodit\JoditWidget::className(), [ 'settings' => [ 'height'=>'250px', 'enableDragAndDropFileToEditor'=>new \yii\web\JsExpression("true"), ], ]);;
Copyecho $form->field($model, 'icon')->widget(\yii2jodit\JoditIconPickerWidget::className(), [ "path" => 'wp-content/plugins/exchangers-monitor/images/systemlogo' ]);
This package is available under MIT
License.