/
v.bolshakov
/
AIEcosystem-Testing
Обзор
Документация
Войти
/
v.bolshakov
/
AIEcosystem-Testing
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
dev
common/widgets/AceEditor.php
71 строка
2 KB
Developer
Initial commit
03 авг 2026, 17:43
03 авг 2026, 17:43
7433917
Код
Авторство
О чём код?
<?php namespace common\widgets; use common\assets\AceEditorAsset; use yii\bootstrap\Html; use yii\bootstrap\InputWidget; use yii\helpers\ArrayHelper; /** * @author Dmitry E. Semenov <sde.tomsk@gmail.com> * @copyright Self (c) 2022 */ class AceEditor extends InputWidget { /** * @inheritdoc */ public function init() { parent::init(); if ($this->hasModel()) { $this->name = ArrayHelper::getValue($this->options, 'name', Html::getInputName($this->model, $this->attribute)); } } /** * @inheritdoc */ public function run() { if ($this->hasModel()) { $ace = Html::getAttributeValue($this->model, $this->attribute); } else { $ace = $this->value; } $this->registerClientScript(); $id = $this->options['id']; $hidden_id = $id . '-hidden'; $height = ArrayHelper::getValue($this->options, 'height', 550); echo Html::hiddenInput($this->name, $ace, [ 'id' => $hidden_id, 'data' => ArrayHelper::getValue($this->options, 'data'), ]); echo Html::tag('div', '', [ 'id' => $id, 'class' => 'editor', 'data' => [ 'hidden_id' => $hidden_id ], 'style' => 'width: 100%; height: ' . $height . 'px;' ]); } /** * Registers AceEditor js */ protected function registerClientScript() { $view = $this->getView(); // подключаем редактор $asset = AceEditorAsset::register($view); } }