如何禁用或删除Yii2 redactor图像和文件按钮?

时间:2018-05-28 06:55:34

标签: php yii2 redactor

我正在使用来自Here Yii2 Redactor。我想删除Image and File Upload

查看代码:

<?= $form->field($model, 'reason')->widget(
\yii\redactor\widgets\Redactor::className(), [])

 ?>

截图

Screen shot

2 个答案:

答案 0 :(得分:7)

如果要隐藏Redactor的所有实例的按钮,可以将其添加到模块配置

'modules' => [
    'redactor' => [
        'class' => 'yii\redactor\RedactorModule',
        'widgetClientOptions' => [
            'buttonsHide' => ['image','file'],
        ]
    ],
],

否则您可以将其添加到单个电话

<?= $form->field($model, 'reason')->widget(\yii\redactor\widgets\Redactor::className(), [
    'clientOptions' => [
        'buttonsHide' => ['image','file'],
    ]
])?>

答案 1 :(得分:-1)

在此库中,您只需更新文件,即路径中的 Redactor.php yii2-主编/部件/ Redactor.php

现在更新方法 defaultOptions 评论或删除92到103之间的行 以下是这些行的代码:

use DBI;
 my $dbh = DBI->connect('DBI:RAM:','usr','pwd',{RaiseError=>1});
 $dbh->func({
    table_name  => 'my_phrases',
    col_names   => 'id,phrase',
    data_type   => 'PIPE',
    data_source => [<DATA>],
 }, 'import' );
 print $dbh->selectcol_arrayref(qq[
   SELECT phrase FROM my_phrases WHERE id = 1
 ])->[0];
 __END__
 1 | Hello, New World
 2 | Some other Phrase