YII2 不通过composer安装Ueditor编辑器

今天用composer安装Ueditor,一直下载失败,不知道为什么,所以就手动安装了一下。记录一下安装步骤

GitHub地址 https://github.com/BigKuCha/yii2-ueditor-widget

首先下载ZIP格式的压缩包,把文件夹重命名为ueditor,并复制到common/widgets下,

修改文件夹下的ueditor.php、ueditorAction.php、ueditorAsset.php、upload.php 中的namespacen改为common\widgets\ueditor

namespace common\widgets\ueditor;

第二步、在调用的controller 文件中添加actions,比如我这里是用在ResourceController中的

<?php


/**
 * ResourceController implements the CRUD actions for Resource model.
 */
class ResourceController extends Controller
{
//code
//... public function actions() { return [ 'upload' => [ 'class' => 'common\widgets\ueditor\UeditorAction', 'config' => [ "imageUrlPrefix" => "",//图片访问路径前缀 "imagePathFormat" => "/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}", "imageRoot" => Yii::getAlias("@webroot"), ], ], ]; } }

  第三步、调用的地方,我这里是_form.php中

    <?php $form = ActiveForm::begin(); ?>

    <?= $form->field($model, 'content')->widget('common\widgets\ueditor\Ueditor',[
        'options'=>[
            'initialFrameWidth' => 650,
        ]
    ]) ?>

    <div class="form-group">
        <?= Html::submitButton('保存', ['class' => 'btn btn-success']) ?>
    </div>

    <?php ActiveForm::end(); ?>

  

 

转载于:https://www.cnblogs.com/intinity/p/9366004.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值