From 1f349aec8489f63c2a6918f236f22f7d356b53b9 Mon Sep 17 00:00:00 2001 From: iIronside Date: Fri, 25 Nov 2022 12:30:43 +0300 Subject: [PATCH] update editor at document template form --- .../document/views/document-template/_form.php | 16 ++++++++++++---- common/models/Document.php | 4 ++-- composer.json | 3 ++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/backend/modules/document/views/document-template/_form.php b/backend/modules/document/views/document-template/_form.php index e1d953c..21e429e 100644 --- a/backend/modules/document/views/document-template/_form.php +++ b/backend/modules/document/views/document-template/_form.php @@ -3,6 +3,7 @@ use asmoday74\ckeditor5\EditorClassic; use backend\modules\document\models\DocumentField; use common\helpers\StatusHelper; +use mihaildev\ckeditor\CKEditor; use yii\helpers\Html; use yii\widgets\ActiveForm; @@ -26,10 +27,17 @@ use yii\widgets\ActiveForm; ] ) ?> - field($model, 'template_body')->widget(EditorClassic::className(), [ - 'clientOptions' => [ - 'language' => 'ru', - ] +field($model, 'template_body')->widget(EditorClassic::className(), [ +// 'clientOptions' => [ +// 'language' => 'ru', +// ] +// ]); ?> + + field($model, 'template_body')->widget(CKEditor::className(),[ + 'editorOptions' => [ + 'preset' => 'full', //разработанны стандартные настройки basic, standard, full данную возможность не обязательно использовать + 'inline' => false, //по умолчанию false + ], ]); ?>
diff --git a/common/models/Document.php b/common/models/Document.php index b27ef06..7e773b7 100644 --- a/common/models/Document.php +++ b/common/models/Document.php @@ -68,9 +68,9 @@ class Document extends \yii\db\ActiveRecord [['manager_id'], 'exist', 'skipOnError' => true, 'targetClass' => Manager::className(), 'targetAttribute' => ['manager_id' => 'id']], ['body', 'required', 'on' => self::SCENARIO_UPDATE_DOCUMENT_BODY], ['body', function ($attribute, $params) { - preg_match_all('/(\${\w+})/', $this->$attribute,$out); + preg_match_all('/(\${\w+|№|№+w})/', $this->$attribute,$out); if (!empty($out[0])) { - $this->addError('body', 'В теле документа все переменные должны бвть заменены!'); + $this->addError('body', 'В теле документа все переменные должны быть заменены!'); } }, 'on' => self::SCENARIO_DOWNLOAD_DOCUMENT ], diff --git a/composer.json b/composer.json index 0800f79..584460e 100755 --- a/composer.json +++ b/composer.json @@ -35,7 +35,8 @@ "kartik-v/yii2-widget-depdrop": "dev-master", "phpoffice/phpword": "^0.18.2", "kartik-v/yii2-widget-fileinput": "@dev", - "kartik-v/yii2-mpdf": "dev-master" + "kartik-v/yii2-mpdf": "dev-master", + "mihaildev/yii2-ckeditor": "*" }, "require-dev": { "yiisoft/yii2-debug": "~2.0.0",